diff --git a/hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/CacheableFileXmlSource.java b/hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/CacheableFileXmlSource.java index 329d58e555..78338ab652 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/CacheableFileXmlSource.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/CacheableFileXmlSource.java @@ -117,9 +117,9 @@ public class CacheableFileXmlSource extends XmlSource { } private static void writeSerFile(Serializable binding, File xmlFile, File serFile) { - try { + try (FileOutputStream fos = new FileOutputStream( serFile )){ log.debugf( "Writing cache file for: %s to: %s", xmlFile.getAbsolutePath(), serFile.getAbsolutePath() ); - SerializationHelper.serialize( binding, new FileOutputStream( serFile ) ); + SerializationHelper.serialize( binding, fos ); boolean success = serFile.setLastModified( System.currentTimeMillis() ); if ( !success ) { log.warn( "Could not update cacheable hbm.xml bin file timestamp" ); diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/AbstractHANADialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/AbstractHANADialect.java index 41fad33f81..59bfccce82 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/AbstractHANADialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/AbstractHANADialect.java @@ -1036,7 +1036,7 @@ public abstract class AbstractHANADialect extends Dialect { createSequenceString += " minvalue " + initialValue; } } - else if ( incrementSize < 0 ) { + else { if ( initialValue > -1 ) { // default maxvalue for a descending sequence is -1 createSequenceString += " maxvalue " + initialValue; diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromElement.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromElement.java index d344de433f..f1352d50ca 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromElement.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromElement.java @@ -279,7 +279,7 @@ public class FromElement extends HqlSqlWalkerNode implements DisplayableNode, Pa if ( columns != null ) { for ( int i = 0; i < columns.length; i++ ) { buf.append( columns[i] ); - if ( i < columns.length ) { + if ( i < columns.length - 1 ) { buf.append( " " ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/jpa/spi/TupleBuilderTransformer.java b/hibernate-core/src/main/java/org/hibernate/jpa/spi/TupleBuilderTransformer.java index 143e9bd73a..00ccef09d1 100644 --- a/hibernate-core/src/main/java/org/hibernate/jpa/spi/TupleBuilderTransformer.java +++ b/hibernate-core/src/main/java/org/hibernate/jpa/spi/TupleBuilderTransformer.java @@ -149,7 +149,7 @@ public class TupleBuilderTransformer extends BasicTransformerAdapter { if ( i < 0 ) { throw new IllegalArgumentException( "requested tuple index must be greater than zero" ); } - if ( i > tuple.length ) { + if ( i >= tuple.length ) { throw new IllegalArgumentException( "requested tuple index exceeds actual tuple size" ); } return tuple[i]; diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java index 3d5c07cb43..acf16a2035 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java @@ -3603,7 +3603,7 @@ public abstract class AbstractEntityPersister // } // // no dirty fields and no dirty collections so no update needed ??? // } - if ( fieldsPreUpdateNeeded.length != 0 && dirtyFields != null ) { + if ( dirtyFields != null ) { dirtyFields = ArrayHelper.join( dirtyFields, ArrayHelper.trim( fieldsPreUpdateNeeded, count ) ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java index 2b4817c82f..b387d1860f 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java @@ -1092,7 +1092,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister { private String[] getSubclassNameClosureBySubclassTable(int subclassTableNumber) { final int index = subclassTableNumber - getTableSpan(); - if ( index > subclassNamesBySubclassTable.length ) { + if ( index >= subclassNamesBySubclassTable.length ) { throw new IllegalArgumentException( "Given subclass table number is outside expected range [" + subclassNamesBySubclassTable.length + "] as defined by subclassTableNameClosure/subclassClosure" diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/AbstractSchemaMigrator.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/AbstractSchemaMigrator.java index 84769b2ab4..e38b3034b0 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/AbstractSchemaMigrator.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/AbstractSchemaMigrator.java @@ -245,7 +245,7 @@ public abstract class AbstractSchemaMigrator implements SchemaMigrator { for ( Table table : namespace.getTables() ) { if ( schemaFilter.includeTable( table ) ) { final TableInformation tableInformation = nameSpaceTablesInformation.getTableInformation( table ); - if ( tableInformation == null || ( tableInformation != null && tableInformation.isPhysicalTable() ) ) { + if ( tableInformation == null || tableInformation.isPhysicalTable() ) { applyForeignKeys( table, tableInformation, dialect, metadata, formatter, options, targets ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/GroupedSchemaMigratorImpl.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/GroupedSchemaMigratorImpl.java index d811ec70fc..aada23b2aa 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/GroupedSchemaMigratorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/GroupedSchemaMigratorImpl.java @@ -70,7 +70,7 @@ public class GroupedSchemaMigratorImpl extends AbstractSchemaMigrator { if ( tableInformation == null ) { createTable( table, dialect, metadata, formatter, options, targets ); } - else if ( tableInformation != null && tableInformation.isPhysicalTable() ) { + else if ( tableInformation.isPhysicalTable() ) { tablesInformation.addTableInformation( tableInformation ); migrateTable( table, tableInformation, dialect, metadata, formatter, options, targets ); } @@ -80,7 +80,7 @@ public class GroupedSchemaMigratorImpl extends AbstractSchemaMigrator { for ( Table table : namespace.getTables() ) { if ( schemaFilter.includeTable( table ) && table.isPhysicalTable() ) { final TableInformation tableInformation = tablesInformation.getTableInformation( table ); - if ( tableInformation == null || ( tableInformation != null && tableInformation.isPhysicalTable() ) ) { + if ( tableInformation == null || tableInformation.isPhysicalTable() ) { applyIndexes( table, tableInformation, dialect, metadata, formatter, options, targets ); applyUniqueKeys( table, tableInformation, dialect, metadata, formatter, options, targets ); } diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/IndividuallySchemaMigratorImpl.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/IndividuallySchemaMigratorImpl.java index 271e41be98..0f2ae8a6dd 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/IndividuallySchemaMigratorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/IndividuallySchemaMigratorImpl.java @@ -70,7 +70,7 @@ public class IndividuallySchemaMigratorImpl extends AbstractSchemaMigrator { if ( tableInformation == null ) { createTable( table, dialect, metadata, formatter, options, targets ); } - else if ( tableInformation != null && tableInformation.isPhysicalTable() ) { + else if ( tableInformation.isPhysicalTable() ) { tablesInformation.addTableInformation( tableInformation ); migrateTable( table, tableInformation, dialect, metadata, formatter, options, targets ); } @@ -80,7 +80,7 @@ public class IndividuallySchemaMigratorImpl extends AbstractSchemaMigrator { for ( Table table : namespace.getTables() ) { if ( schemaFilter.includeTable( table ) && table.isPhysicalTable() ) { final TableInformation tableInformation = tablesInformation.getTableInformation( table ); - if ( tableInformation == null || ( tableInformation != null && tableInformation.isPhysicalTable() ) ) { + if ( tableInformation == null || tableInformation.isPhysicalTable() ) { applyIndexes( table, tableInformation, dialect, metadata, formatter, options, targets ); applyUniqueKeys( table, tableInformation, dialect, metadata, formatter, options, targets ); }