From bb5a47086d9d3e616941415830afe722a73a2bc8 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Mon, 24 Aug 2020 14:43:40 +0200 Subject: [PATCH 1/3] HHH-14183 LocalTimeJavaDescriptor attempts casting to LocalDate --- .../hibernate/type/descriptor/java/LocalTimeJavaDescriptor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/LocalTimeJavaDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/LocalTimeJavaDescriptor.java index e805ff23a9..cd5d7bc6b2 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/LocalTimeJavaDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/LocalTimeJavaDescriptor.java @@ -54,7 +54,7 @@ public class LocalTimeJavaDescriptor extends AbstractTypeDescriptor { return null; } - if ( LocalDate.class.isAssignableFrom( type ) ) { + if ( LocalTime.class.isAssignableFrom( type ) ) { return (X) value; } From e3063f48589e10b01693e4b94d367b43cac9de73 Mon Sep 17 00:00:00 2001 From: Falko Modler Date: Sun, 23 Aug 2020 19:02:00 +0200 Subject: [PATCH 2/3] HHH-14179 fix MultiLineImportExtractorTest on Windows --- .../test/fileimport/MultiLineImportExtractorTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/test/fileimport/MultiLineImportExtractorTest.java b/hibernate-core/src/test/java/org/hibernate/test/fileimport/MultiLineImportExtractorTest.java index d1d4aa08a1..abd3f8a0e9 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/fileimport/MultiLineImportExtractorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/fileimport/MultiLineImportExtractorTest.java @@ -40,11 +40,13 @@ public class MultiLineImportExtractorTest { assertThat( commands, notNullValue() ); assertThat( commands.length, is( 6 ) ); + // for Windows compatibility, System.lineSeparator() has to be used instead of just "\n" + assertThat( commands[0], startsWith( "CREATE TABLE test_data" ) ); assertThat( commands[1], is( "INSERT INTO test_data VALUES (1, 'sample')" ) ); - assertThat( commands[2], is( "DELETE\n FROM test_data" ) ); + assertThat( commands[2], is( "DELETE" + System.lineSeparator() + " FROM test_data" ) ); assertThat( commands[3], startsWith( "INSERT INTO test_data VALUES (2," ) ); assertThat( commands[3], containsString( "-- line 2" ) ); @@ -52,7 +54,7 @@ public class MultiLineImportExtractorTest { assertThat( commands[4], startsWith( "INSERT INTO test_data VALUES (3" ) ); assertThat( commands[4], not( containsString( "third record" ) ) ); - assertThat( commands[5], startsWith( "INSERT INTO test_data\nVALUES\n" ) ); + assertThat( commands[5], startsWith( "INSERT INTO test_data" + System.lineSeparator() + "VALUES" + System.lineSeparator() ) ); } } } From 9ded66b90f94135aff332969f8c49e3a403712c7 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Sun, 23 Aug 2020 09:32:06 +0200 Subject: [PATCH 3/3] HHH-14181 Fix bug where HQL update/delete query resulted in same table being updated twice for HQL bulk update/delete against union-subclass mapping also clean up iterator usage in that section of code --- .../entity/UnionSubclassEntityPersister.java | 41 ++++++++----------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/UnionSubclassEntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/UnionSubclassEntityPersister.java index b717086fe4..5112857986 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/UnionSubclassEntityPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/UnionSubclassEntityPersister.java @@ -144,12 +144,12 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister { persistentClass.getEntityName() ); if ( persistentClass.isPolymorphic() ) { - Iterator iter = persistentClass.getSubclassIterator(); + Iterator subclassIter = persistentClass.getSubclassIterator(); int k = 1; - while ( iter.hasNext() ) { - Subclass sc = (Subclass) iter.next(); - subclassClosure[k++] = sc.getEntityName(); - subclassByDiscriminatorValue.put( sc.getSubclassId(), sc.getEntityName() ); + while ( subclassIter.hasNext() ) { + Subclass subclass = subclassIter.next(); + subclassClosure[k++] = subclass.getEntityName(); + subclassByDiscriminatorValue.put( subclass.getSubclassId(), subclass.getEntityName() ); } } @@ -160,16 +160,15 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister { int spacesSize = 1 + persistentClass.getSynchronizedTables().size(); spaces = new String[spacesSize]; spaces[0] = tableName; - Iterator iter = persistentClass.getSynchronizedTables().iterator(); + Iterator iter = persistentClass.getSynchronizedTables().iterator(); for ( int i = 1; i < spacesSize; i++ ) { - spaces[i] = (String) iter.next(); + spaces[i] = iter.next(); } - HashSet subclassTables = new HashSet(); - iter = persistentClass.getSubclassTableClosureIterator(); - while ( iter.hasNext() ) { - final Table table = (Table) iter.next(); - subclassTables.add( determineTableName( table, jdbcEnvironment ) ); + HashSet subclassTables = new HashSet(); + Iterator subclassTableIter = persistentClass.getSubclassTableClosureIterator(); + while ( subclassTableIter.hasNext() ) { + subclassTables.add( determineTableName( subclassTableIter.next(), jdbcEnvironment ) ); } subclassSpaces = ArrayHelper.toStringArray( subclassTables ); @@ -177,22 +176,18 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister { if ( isMultiTable() ) { int idColumnSpan = getIdentifierColumnSpan(); - ArrayList tableNames = new ArrayList(); - ArrayList keyColumns = new ArrayList(); - if ( !isAbstract() ) { - tableNames.add( tableName ); - keyColumns.add( getIdentifierColumnNames() ); - } - iter = persistentClass.getSubclassTableClosureIterator(); - while ( iter.hasNext() ) { - Table tab = (Table) iter.next(); + ArrayList tableNames = new ArrayList<>(); + ArrayList keyColumns = new ArrayList<>(); + Iterator
tableIter = persistentClass.getSubclassTableClosureIterator(); + while ( tableIter.hasNext() ) { + Table tab = tableIter.next(); if ( !tab.isAbstractUnionTable() ) { final String tableName = determineTableName( tab, jdbcEnvironment ); tableNames.add( tableName ); String[] key = new String[idColumnSpan]; - Iterator citer = tab.getPrimaryKey().getColumnIterator(); + Iterator citer = tab.getPrimaryKey().getColumnIterator(); for ( int k = 0; k < idColumnSpan; k++ ) { - key[k] = ( (Column) citer.next() ).getQuotedName( factory.getDialect() ); + key[k] = citer.next().getQuotedName( factory.getDialect() ); } keyColumns.add( key ); }