Merge remote-tracking branch 'upstream/master' into wip/6.0

This commit is contained in:
Andrea Boriero 2020-08-25 09:13:28 +01:00
commit f5ba3c22a0
2 changed files with 18 additions and 24 deletions

View File

@ -154,11 +154,10 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
persistentClass.getEntityName()
);
if ( persistentClass.isPolymorphic() ) {
Iterator iter = persistentClass.getSubclassIterator();
int k = 1;
while ( iter.hasNext() ) {
Subclass sc = (Subclass) iter.next();
subclassByDiscriminatorValue.put( sc.getSubclassId(), sc.getEntityName() );
Iterator<Subclass> subclassIter = persistentClass.getSubclassIterator();
while ( subclassIter.hasNext() ) {
Subclass subclass = subclassIter.next();
subclassByDiscriminatorValue.put( subclass.getSubclassId(), subclass.getEntityName() );
}
}
@ -169,16 +168,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<String> 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<String> subclassTables = new HashSet();
Iterator<Table> subclassTableIter = persistentClass.getSubclassTableClosureIterator();
while ( subclassTableIter.hasNext() ) {
subclassTables.add( determineTableName( subclassTableIter.next(), jdbcEnvironment ) );
}
subclassSpaces = ArrayHelper.toStringArray( subclassTables );
@ -186,22 +184,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<String> tableNames = new ArrayList<>();
ArrayList<String[]> keyColumns = new ArrayList<>();
Iterator<Table> 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<Column> 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 );
}

View File

@ -54,7 +54,7 @@ public class MultiLineImportExtractorTest {
assertThat( commands.get( 4 ), startsWith( "INSERT INTO test_data VALUES (3" ) );
assertThat( commands.get( 4 ), not( containsString( "third record" ) ) );
assertThat( commands.get( 5 ), startsWith( "INSERT INTO test_data\nVALUES\n" ) );
assertThat( commands.get( 5 ), startsWith( "INSERT INTO test_data" + System.lineSeparator() + "VALUES" ) );
}
}
}