get rid of more iterators in the mapping package

This commit is contained in:
Gavin King 2022-01-26 20:29:10 +01:00
parent 54b9677d99
commit 12a515a95a
12 changed files with 140 additions and 75 deletions

View File

@ -478,7 +478,7 @@ public class BinderHelper {
catch (MappingException me) { catch (MappingException me) {
//swallow it //swallow it
} }
Iterator joins = current.getJoinIterator(); Iterator<Join> joins = current.getJoinIterator();
while ( !found && joins.hasNext() ) { while ( !found && joins.hasNext() ) {
result = joins.next(); result = joins.next();
currentTable = ( (Join) result ).getTable(); currentTable = ( (Join) result ).getTable();

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate.cfg; package org.hibernate.cfg;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinColumn;
@ -27,7 +26,6 @@ import org.hibernate.mapping.ManyToOne;
import org.hibernate.mapping.OneToOne; import org.hibernate.mapping.OneToOne;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property; import org.hibernate.mapping.Property;
import org.hibernate.mapping.Selectable;
import org.hibernate.mapping.SortableValue; import org.hibernate.mapping.SortableValue;
import org.hibernate.type.ForeignKeyDirection; import org.hibernate.type.ForeignKeyDirection;
@ -176,10 +174,8 @@ public class OneToOneSecondPass implements SecondPass {
propertyHolder.addProperty( prop, inferredData.getDeclaringClass() ); propertyHolder.addProperty( prop, inferredData.getDeclaringClass() );
} }
else if ( otherSideProperty.getValue() instanceof ManyToOne ) { else if ( otherSideProperty.getValue() instanceof ManyToOne ) {
Iterator<Join> it = otherSide.getJoinIterator();
Join otherSideJoin = null; Join otherSideJoin = null;
while ( it.hasNext() ) { for ( Join otherSideJoinValue : otherSide.getJoins() ) {
Join otherSideJoinValue = it.next();
if ( otherSideJoinValue.containsProperty( otherSideProperty ) ) { if ( otherSideJoinValue.containsProperty( otherSideProperty ) ) {
otherSideJoin = otherSideJoinValue; otherSideJoin = otherSideJoinValue;
break; break;

View File

@ -2020,10 +2020,8 @@ public abstract class CollectionBinder {
} }
else { else {
//find the appropriate reference key, can be in a join //find the appropriate reference key, can be in a join
Iterator<Join> joinsIt = referencedEntity.getJoinIterator();
KeyValue key = null; KeyValue key = null;
while ( joinsIt.hasNext() ) { for ( Join join : referencedEntity.getJoins() ) {
Join join = joinsIt.next();
if ( join.containsProperty( property ) ) { if ( join.containsProperty( property ) ) {
key = join.getKey(); key = join.getKey();
break; break;

View File

@ -31,6 +31,7 @@ import org.hibernate.MappingException;
import org.hibernate.annotations.BatchSize; import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache; import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy; import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Columns;
import org.hibernate.annotations.Comment; import org.hibernate.annotations.Comment;
import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate; import org.hibernate.annotations.DynamicUpdate;
@ -844,12 +845,12 @@ public class EntityBinder {
* Those operations has to be done after the id definition of the persistence class. * Those operations has to be done after the id definition of the persistence class.
* ie after the properties parsing * ie after the properties parsing
*/ */
Iterator joins = secondaryTables.values().iterator(); Iterator<Join> joins = secondaryTables.values().iterator();
Iterator joinColumns = secondaryTableJoins.values().iterator(); Iterator<Object> joinColumns = secondaryTableJoins.values().iterator();
while ( joins.hasNext() ) { while ( joins.hasNext() ) {
Object uncastedColumn = joinColumns.next(); Object uncastedColumn = joinColumns.next();
Join join = (Join) joins.next(); Join join = joins.next();
createPrimaryColumnsToSecondaryTable( uncastedColumn, propertyHolder, join ); createPrimaryColumnsToSecondaryTable( uncastedColumn, propertyHolder, join );
} }
} }
@ -1203,16 +1204,13 @@ public class EntityBinder {
//comment and index are processed here //comment and index are processed here
if ( table == null ) return; if ( table == null ) return;
String appliedTable = table.appliesTo(); String appliedTable = table.appliesTo();
Iterator tables = persistentClass.getTableClosureIterator();
Table hibTable = null; Table hibTable = null;
while ( tables.hasNext() ) { for ( Table pcTable : persistentClass.getTableClosure() ) {
Table pcTable = (Table) tables.next();
if ( pcTable.getQuotedName().equals( appliedTable ) ) { if ( pcTable.getQuotedName().equals( appliedTable ) ) {
//we are in the correct table to find columns //we are in the correct table to find columns
hibTable = pcTable; hibTable = pcTable;
break; break;
} }
hibTable = null;
} }
if ( hibTable == null ) { if ( hibTable == null ) {
//maybe a join/secondary table //maybe a join/secondary table

View File

@ -323,6 +323,9 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
@Deprecated(since = "6.0") @Deprecated(since = "6.0")
public abstract Iterator<Property> getPropertyClosureIterator(); public abstract Iterator<Property> getPropertyClosureIterator();
public abstract List<Table> getTableClosure();
@Deprecated(since = "6.0")
public abstract Iterator<Table> getTableClosureIterator(); public abstract Iterator<Table> getTableClosureIterator();
public abstract Iterator<KeyValue> getKeyClosureIterator(); public abstract Iterator<KeyValue> getKeyClosureIterator();
@ -360,10 +363,20 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
return new JoinedList<>( lists ); return new JoinedList<>( lists );
} }
@Deprecated(since = "6.0")
public Iterator<Join> getSubclassJoinClosureIterator() { public Iterator<Join> getSubclassJoinClosureIterator() {
return new JoinedIterator<>( getJoinClosureIterator(), subclassJoins.iterator() ); return new JoinedIterator<>( getJoinClosureIterator(), subclassJoins.iterator() );
} }
public List<Join> getSubclassJoinClosure() {
return new JoinedList<>( getJoinClosure(), subclassJoins );
}
public List<Table> getSubclassTableClosure() {
return new JoinedList<>( getTableClosure(), subclassTables );
}
@Deprecated(since = "6.0")
public Iterator<Table> getSubclassTableClosureIterator() { public Iterator<Table> getSubclassTableClosureIterator() {
return new JoinedIterator<>( getTableClosureIterator(), subclassTables.iterator() ); return new JoinedIterator<>( getTableClosureIterator(), subclassTables.iterator() );
} }
@ -712,10 +725,20 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
return getClass().getName() + '(' + getEntityName() + ')'; return getClass().getName() + '(' + getEntityName() + ')';
} }
public List<Join> getJoins() {
return joins;
}
public List<Join> getJoinClosure() {
return joins;
}
@Deprecated(since = "6.0")
public Iterator<Join> getJoinIterator() { public Iterator<Join> getJoinIterator() {
return joins.iterator(); return joins.iterator();
} }
@Deprecated(since = "6.0")
public Iterator<Join> getJoinClosureIterator() { public Iterator<Join> getJoinClosureIterator() {
return joins.iterator(); return joins.iterator();
} }
@ -739,9 +762,7 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
public int getJoinNumber(Property prop) { public int getJoinNumber(Property prop) {
int result = 1; int result = 1;
Iterator<Join> iter = getSubclassJoinClosureIterator(); for ( Join join : getSubclassJoinClosure() ) {
while ( iter.hasNext() ) {
Join join = iter.next();
if ( join.containsProperty( prop ) ) { if ( join.containsProperty( prop ) ) {
return result; return result;
} }
@ -998,10 +1019,8 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
} }
checkColumnDuplication( cols, getDiscriminator() ); checkColumnDuplication( cols, getDiscriminator() );
checkPropertyColumnDuplication( cols, getNonDuplicatedProperties() ); checkPropertyColumnDuplication( cols, getNonDuplicatedProperties() );
Iterator<Join> iter = getJoinIterator(); for ( Join join : getJoins() ) {
while ( iter.hasNext() ) {
cols.clear(); cols.clear();
Join join = iter.next();
checkColumnDuplication( cols, join.getKey() ); checkColumnDuplication( cols, join.getKey() );
checkPropertyColumnDuplication( cols, join.getProperties() ); checkPropertyColumnDuplication( cols, join.getProperties() );
} }

View File

@ -136,11 +136,16 @@ public class RootClass extends PersistentClass implements TableOwner {
return getProperties(); return getProperties();
} }
@Override @Override @Deprecated
public Iterator<Table> getTableClosureIterator() { public Iterator<Table> getTableClosureIterator() {
return new SingletonIterator<>( getTable() ); return new SingletonIterator<>( getTable() );
} }
@Override
public List<Table> getTableClosure() {
return List.of( getTable() );
}
@Override @Override
public Iterator<KeyValue> getKeyClosureIterator() { public Iterator<KeyValue> getKeyClosureIterator() {
return new SingletonIterator<>( getKey() ); return new SingletonIterator<>( getKey() );
@ -344,13 +349,12 @@ public class RootClass extends PersistentClass implements TableOwner {
return synchronizedTables; return synchronizedTables;
} }
@SuppressWarnings("UnnecessaryUnboxing")
public Set<Table> getIdentityTables() { public Set<Table> getIdentityTables() {
Set<Table> tables = new HashSet<>(); Set<Table> tables = new HashSet<>();
Iterator iter = getSubclassClosureIterator(); Iterator<PersistentClass> iter = getSubclassClosureIterator();
while ( iter.hasNext() ) { while ( iter.hasNext() ) {
PersistentClass clazz = (PersistentClass) iter.next(); PersistentClass clazz = iter.next();
if ( clazz.isAbstract() == null || !clazz.isAbstract().booleanValue() ) { if ( clazz.isAbstract() == null || !clazz.isAbstract() ) {
tables.add( clazz.getIdentityTable() ); tables.add( clazz.getIdentityTable() );
} }
} }

View File

@ -38,10 +38,12 @@ public class Subclass extends PersistentClass {
this.subclassId = superclass.nextSubclassId(); this.subclassId = superclass.nextSubclassId();
} }
@Override
int nextSubclassId() { int nextSubclassId() {
return getSuperclass().nextSubclassId(); return getSuperclass().nextSubclassId();
} }
@Override
public int getSubclassId() { public int getSubclassId() {
return subclassId; return subclassId;
} }
@ -51,55 +53,74 @@ public class Subclass extends PersistentClass {
return getSuperclass().getNaturalIdCacheRegionName(); return getSuperclass().getNaturalIdCacheRegionName();
} }
@Override
public String getCacheConcurrencyStrategy() { public String getCacheConcurrencyStrategy() {
return getRootClass().getCacheConcurrencyStrategy(); return getRootClass().getCacheConcurrencyStrategy();
} }
@Override
public RootClass getRootClass() { public RootClass getRootClass() {
return getSuperclass().getRootClass(); return getSuperclass().getRootClass();
} }
@Override
public PersistentClass getSuperclass() { public PersistentClass getSuperclass() {
return superclass; return superclass;
} }
@Override
public Property getIdentifierProperty() { public Property getIdentifierProperty() {
return getSuperclass().getIdentifierProperty(); return getSuperclass().getIdentifierProperty();
} }
@Override
public Property getDeclaredIdentifierProperty() { public Property getDeclaredIdentifierProperty() {
return null; return null;
} }
@Override
public KeyValue getIdentifier() { public KeyValue getIdentifier() {
return getSuperclass().getIdentifier(); return getSuperclass().getIdentifier();
} }
@Override
public boolean hasIdentifierProperty() { public boolean hasIdentifierProperty() {
return getSuperclass().hasIdentifierProperty(); return getSuperclass().hasIdentifierProperty();
} }
@Override
public Value getDiscriminator() { public Value getDiscriminator() {
return getSuperclass().getDiscriminator(); return getSuperclass().getDiscriminator();
} }
@Override
public boolean isMutable() { public boolean isMutable() {
return getSuperclass().isMutable(); return getSuperclass().isMutable();
} }
@Override
public boolean isInherited() { public boolean isInherited() {
return true; return true;
} }
@Override
public boolean isPolymorphic() { public boolean isPolymorphic() {
return true; return true;
} }
@Override
public void addProperty(Property p) { public void addProperty(Property p) {
super.addProperty(p); super.addProperty(p);
getSuperclass().addSubclassProperty(p); getSuperclass().addSubclassProperty(p);
} }
@Override
public void addMappedsuperclassProperty(Property p) { public void addMappedsuperclassProperty(Property p) {
super.addMappedsuperclassProperty( p ); super.addMappedsuperclassProperty( p );
getSuperclass().addSubclassProperty(p); getSuperclass().addSubclassProperty(p);
} }
@Override
public void addJoin(Join j) { public void addJoin(Join j) {
super.addJoin(j); super.addJoin(j);
getSuperclass().addSubclassJoin(j); getSuperclass().addSubclassJoin(j);
@ -110,7 +131,7 @@ public class Subclass extends PersistentClass {
return new JoinedList<>( getSuperclass().getPropertyClosure(), getProperties() ); return new JoinedList<>( getSuperclass().getPropertyClosure(), getProperties() );
} }
@Deprecated @Deprecated @Override
public Iterator<Property> getPropertyClosureIterator() { public Iterator<Property> getPropertyClosureIterator() {
return new JoinedIterator<>( return new JoinedIterator<>(
getSuperclass().getPropertyClosureIterator(), getSuperclass().getPropertyClosureIterator(),
@ -118,60 +139,86 @@ public class Subclass extends PersistentClass {
); );
} }
@Deprecated @Override
public Iterator<Table> getTableClosureIterator() { public Iterator<Table> getTableClosureIterator() {
return new JoinedIterator<>( return new JoinedIterator<>(
getSuperclass().getTableClosureIterator(), getSuperclass().getTableClosureIterator(),
new SingletonIterator<>( getTable() ) new SingletonIterator<>( getTable() )
); );
} }
@Override
public List<Table> getTableClosure() {
return new JoinedList<>(
getSuperclass().getTableClosure(),
List.of( getTable() )
);
}
@Override
public Iterator<KeyValue> getKeyClosureIterator() { public Iterator<KeyValue> getKeyClosureIterator() {
return new JoinedIterator<>( return new JoinedIterator<>(
getSuperclass().getKeyClosureIterator(), getSuperclass().getKeyClosureIterator(),
new SingletonIterator<>( getKey() ) new SingletonIterator<>( getKey() )
); );
} }
@Override
protected void addSubclassProperty(Property p) { protected void addSubclassProperty(Property p) {
super.addSubclassProperty(p); super.addSubclassProperty(p);
getSuperclass().addSubclassProperty(p); getSuperclass().addSubclassProperty(p);
} }
@Override
protected void addSubclassJoin(Join j) { protected void addSubclassJoin(Join j) {
super.addSubclassJoin(j); super.addSubclassJoin(j);
getSuperclass().addSubclassJoin(j); getSuperclass().addSubclassJoin(j);
} }
@Override
protected void addSubclassTable(Table table) { protected void addSubclassTable(Table table) {
super.addSubclassTable(table); super.addSubclassTable(table);
getSuperclass().addSubclassTable(table); getSuperclass().addSubclassTable(table);
} }
@Override
public boolean isVersioned() { public boolean isVersioned() {
return getSuperclass().isVersioned(); return getSuperclass().isVersioned();
} }
@Override
public Property getVersion() { public Property getVersion() {
return getSuperclass().getVersion(); return getSuperclass().getVersion();
} }
@Override
public Property getDeclaredVersion() { public Property getDeclaredVersion() {
return null; return null;
} }
@Override
public boolean hasEmbeddedIdentifier() { public boolean hasEmbeddedIdentifier() {
return getSuperclass().hasEmbeddedIdentifier(); return getSuperclass().hasEmbeddedIdentifier();
} }
@Override
public Class<? extends EntityPersister> getEntityPersisterClass() { public Class<? extends EntityPersister> getEntityPersisterClass() {
return classPersisterClass == null return classPersisterClass == null
? getSuperclass().getEntityPersisterClass() ? getSuperclass().getEntityPersisterClass()
: classPersisterClass; : classPersisterClass;
} }
@Override
public Table getRootTable() { public Table getRootTable() {
return getSuperclass().getRootTable(); return getSuperclass().getRootTable();
} }
@Override
public KeyValue getKey() { public KeyValue getKey() {
return getSuperclass().getIdentifier(); return getSuperclass().getIdentifier();
} }
@Override
public boolean isExplicitPolymorphism() { public boolean isExplicitPolymorphism() {
return getSuperclass().isExplicitPolymorphism(); return getSuperclass().isExplicitPolymorphism();
} }
@ -180,10 +227,12 @@ public class Subclass extends PersistentClass {
this.superclass = superclass; this.superclass = superclass;
} }
@Override
public String getWhere() { public String getWhere() {
return getSuperclass().getWhere(); return getSuperclass().getWhere();
} }
@Override
public boolean isJoinedSubclass() { public boolean isJoinedSubclass() {
return getTable()!=getRootTable(); return getTable()!=getRootTable();
} }
@ -195,18 +244,28 @@ public class Subclass extends PersistentClass {
getKey().createForeignKeyOfEntity( getSuperclass().getEntityName() ); getKey().createForeignKeyOfEntity( getSuperclass().getEntityName() );
} }
@Override
public void setEntityPersisterClass(Class<? extends EntityPersister> classPersisterClass) { public void setEntityPersisterClass(Class<? extends EntityPersister> classPersisterClass) {
this.classPersisterClass = classPersisterClass; this.classPersisterClass = classPersisterClass;
} }
@Override
public int getJoinClosureSpan() { public int getJoinClosureSpan() {
return getSuperclass().getJoinClosureSpan() + super.getJoinClosureSpan(); return getSuperclass().getJoinClosureSpan() + super.getJoinClosureSpan();
} }
@Override
public int getPropertyClosureSpan() { public int getPropertyClosureSpan() {
return getSuperclass().getPropertyClosureSpan() + super.getPropertyClosureSpan(); return getSuperclass().getPropertyClosureSpan() + super.getPropertyClosureSpan();
} }
@Override
public List<Join> getJoinClosure() {
return new JoinedList<>( getSuperclass().getJoinClosure(), super.getJoinClosure() );
}
@Deprecated(since = "6.0")
public Iterator<Join> getJoinClosureIterator() { public Iterator<Join> getJoinClosureIterator() {
return new JoinedIterator<>( return new JoinedIterator<>(
getSuperclass().getJoinClosureIterator(), getSuperclass().getJoinClosureIterator(),
@ -214,26 +273,33 @@ public class Subclass extends PersistentClass {
); );
} }
@Override
public boolean isClassOrSuperclassJoin(Join join) { public boolean isClassOrSuperclassJoin(Join join) {
return super.isClassOrSuperclassJoin(join) || getSuperclass().isClassOrSuperclassJoin(join); return super.isClassOrSuperclassJoin(join) || getSuperclass().isClassOrSuperclassJoin(join);
} }
@Override
public boolean isClassOrSuperclassTable(Table table) { public boolean isClassOrSuperclassTable(Table table) {
return super.isClassOrSuperclassTable(table) || getSuperclass().isClassOrSuperclassTable(table); return super.isClassOrSuperclassTable(table) || getSuperclass().isClassOrSuperclassTable(table);
} }
@Override
public Table getTable() { public Table getTable() {
return getSuperclass().getTable(); return getSuperclass().getTable();
} }
@Override
public boolean isForceDiscriminator() { public boolean isForceDiscriminator() {
return getSuperclass().isForceDiscriminator(); return getSuperclass().isForceDiscriminator();
} }
@Override
public boolean isDiscriminatorInsertable() { public boolean isDiscriminatorInsertable() {
return getSuperclass().isDiscriminatorInsertable(); return getSuperclass().isDiscriminatorInsertable();
} }
@Override
public java.util.Set<String> getSynchronizedTables() { public java.util.Set<String> getSynchronizedTables() {
HashSet<String> result = new HashSet<>(); HashSet<String> result = new HashSet<>();
result.addAll(synchronizedTables); result.addAll(synchronizedTables);
@ -241,21 +307,25 @@ public class Subclass extends PersistentClass {
return result; return result;
} }
@Override
public Object accept(PersistentClassVisitor mv) { public Object accept(PersistentClassVisitor mv) {
return mv.accept(this); return mv.accept(this);
} }
@Override
public java.util.List<FilterConfiguration> getFilters() { public java.util.List<FilterConfiguration> getFilters() {
java.util.List<FilterConfiguration> filters = new ArrayList<>(super.getFilters()); java.util.List<FilterConfiguration> filters = new ArrayList<>(super.getFilters());
filters.addAll(getSuperclass().getFilters()); filters.addAll(getSuperclass().getFilters());
return filters; return filters;
} }
@Override
public boolean hasSubselectLoadableCollections() { public boolean hasSubselectLoadableCollections() {
return super.hasSubselectLoadableCollections() || return super.hasSubselectLoadableCollections() ||
getSuperclass().hasSubselectLoadableCollections(); getSuperclass().hasSubselectLoadableCollections();
} }
@Override
public String getTuplizerImplClassName(RepresentationMode mode) { public String getTuplizerImplClassName(RepresentationMode mode) {
String impl = super.getTuplizerImplClassName( mode ); String impl = super.getTuplizerImplClassName( mode );
if ( impl == null ) { if ( impl == null ) {
@ -264,6 +334,7 @@ public class Subclass extends PersistentClass {
return impl; return impl;
} }
@Override
public Map getTuplizerMap() { public Map getTuplizerMap() {
Map specificTuplizerDefs = super.getTuplizerMap(); Map specificTuplizerDefs = super.getTuplizerMap();
Map superclassTuplizerDefs = getSuperclass().getTuplizerMap(); Map superclassTuplizerDefs = getSuperclass().getTuplizerMap();
@ -282,6 +353,7 @@ public class Subclass extends PersistentClass {
} }
} }
@Override
public Component getIdentifierMapper() { public Component getIdentifierMapper() {
return superclass.getIdentifierMapper(); return superclass.getIdentifierMapper();
} }

View File

@ -223,9 +223,7 @@ public class ToOneAttributeMapping
.getEntityBinding( manyToOne.getReferencedEntityName() ); .getEntityBinding( manyToOne.getReferencedEntityName() );
if ( cardinality == Cardinality.LOGICAL_ONE_TO_ONE ) { if ( cardinality == Cardinality.LOGICAL_ONE_TO_ONE ) {
// Handle join table cases // Handle join table cases
final Iterator<Join> joinClosureIterator = entityBinding.getJoinClosureIterator(); for ( Join join : entityBinding.getJoinClosure() ) {
while ( joinClosureIterator.hasNext() ) {
final Join join = joinClosureIterator.next();
if ( join.getPersistentClass().getEntityName().equals( entityBinding.getEntityName() ) if ( join.getPersistentClass().getEntityName().equals( entityBinding.getEntityName() )
&& join.getPropertySpan() == 1 && join.getPropertySpan() == 1
&& join.getTable() == manyToOne.getTable() && join.getTable() == manyToOne.getTable()

View File

@ -282,10 +282,8 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
isNullableTable = new boolean[tableSpan]; isNullableTable = new boolean[tableSpan];
isInverseTable = new boolean[tableSpan]; isInverseTable = new boolean[tableSpan];
Iterator<Join> joinItr = persistentClass.getJoinClosureIterator(); int tableIndex = 0;
for ( int tableIndex = 0; joinItr.hasNext(); tableIndex++ ) { for ( Join join : persistentClass.getJoinClosure() ) {
Join join = joinItr.next();
isNullableTable[tableIndex] = join.isOptional(); isNullableTable[tableIndex] = join.isOptional();
isInverseTable[tableIndex] = join.isInverse(); isInverseTable[tableIndex] = join.isInverse();
@ -311,6 +309,8 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
keyColumnReaders.add( keyColReaders ); keyColumnReaders.add( keyColReaders );
keyColumnReaderTemplates.add( keyColReaderTemplates ); keyColumnReaderTemplates.add( keyColReaderTemplates );
cascadeDeletes.add( key.isCascadeDeleteEnabled() && factory.getJdbcServices().getDialect().supportsCascadeDelete() ); cascadeDeletes.add( key.isCascadeDeleteEnabled() && factory.getJdbcServices().getDialect().supportsCascadeDelete() );
tableIndex++;
} }
naturalOrderTableNames = ArrayHelper.toStringArray( tableNames ); naturalOrderTableNames = ArrayHelper.toStringArray( tableNames );
@ -327,18 +327,16 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
ArrayList<Boolean> isNullables = new ArrayList<>(); ArrayList<Boolean> isNullables = new ArrayList<>();
keyColumns = new ArrayList<>(); keyColumns = new ArrayList<>();
tItr = persistentClass.getSubclassTableClosureIterator(); for ( Table table : persistentClass.getSubclassTableClosure() ) {
while ( tItr.hasNext() ) { isConcretes.add( persistentClass.isClassOrSuperclassTable( table ) );
Table tab = tItr.next();
isConcretes.add( persistentClass.isClassOrSuperclassTable( tab ) );
isDeferreds.add( Boolean.FALSE ); isDeferreds.add( Boolean.FALSE );
isLazies.add( Boolean.FALSE ); isLazies.add( Boolean.FALSE );
isInverses.add( Boolean.FALSE ); isInverses.add( Boolean.FALSE );
isNullables.add( Boolean.FALSE ); isNullables.add( Boolean.FALSE );
final String tableName = determineTableName( tab ); final String tableName = determineTableName( table );
subclassTableNames.add( tableName ); subclassTableNames.add( tableName );
String[] key = new String[idColumnSpan]; String[] key = new String[idColumnSpan];
List<Column> columns = tab.getPrimaryKey().getColumns(); List<Column> columns = table.getPrimaryKey().getColumns();
for ( int k = 0; k < idColumnSpan; k++ ) { for ( int k = 0; k < idColumnSpan; k++ ) {
key[k] = columns.get(k).getQuotedName( factory.getJdbcServices().getDialect() ); key[k] = columns.get(k).getQuotedName( factory.getJdbcServices().getDialect() );
} }
@ -346,9 +344,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
} }
//Add joins //Add joins
joinItr = persistentClass.getSubclassJoinClosureIterator(); for ( Join join : persistentClass.getSubclassJoinClosure() ) {
while ( joinItr.hasNext() ) {
final Join join = joinItr.next();
final Table joinTable = join.getTable(); final Table joinTable = join.getTable();
isConcretes.add( persistentClass.isClassOrSuperclassTable( joinTable ) ); isConcretes.add( persistentClass.isClassOrSuperclassTable( joinTable ) );
@ -446,11 +442,8 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
throw new AssertionFailure( "Tablespan does not match height of joined-subclass hiearchy." ); throw new AssertionFailure( "Tablespan does not match height of joined-subclass hiearchy." );
} }
joinItr = persistentClass.getJoinClosureIterator();
int j = coreTableSpan; int j = coreTableSpan;
while ( joinItr.hasNext() ) { for ( Join join : persistentClass.getJoinClosure() ) {
Join join = joinItr.next();
isInverseTable[j] = join.isInverse(); isInverseTable[j] = join.isInverse();
isNullableTable[j] = join.isOptional(); isNullableTable[j] = join.isOptional();
@ -746,9 +739,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
associateSubclassNamesToSubclassTableIndex( tableName, classNames, mapping ); associateSubclassNamesToSubclassTableIndex( tableName, classNames, mapping );
Iterator<Join> itr = persistentClass.getJoinIterator(); for ( Join join : persistentClass.getJoins() ) {
while ( itr.hasNext() ) {
final Join join = itr.next();
final String secondaryTableName = join.getTable().getQualifiedName( final String secondaryTableName = join.getTable().getQualifiedName(
factory.getSqlStringGenerationContext() factory.getSqlStringGenerationContext()
); );

View File

@ -187,11 +187,9 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
// JOINS // JOINS
Iterator<Join> joinIter = persistentClass.getJoinClosureIterator();
int j = 1; int j = 1;
final Dialect dialect = factory.getJdbcServices().getDialect(); final Dialect dialect = factory.getJdbcServices().getDialect();
while ( joinIter.hasNext() ) { for ( Join join : persistentClass.getJoinClosure() ) {
Join join = joinIter.next();
qualifiedTableNames[j] = determineTableName( join.getTable() ); qualifiedTableNames[j] = determineTableName( join.getTable() );
isInverseTable[j] = join.isInverse(); isInverseTable[j] = join.isInverse();
isNullableTable[j] = join.isOptional(); isNullableTable[j] = join.isOptional();
@ -253,9 +251,7 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
isInverses.add( Boolean.FALSE ); isInverses.add( Boolean.FALSE );
isNullables.add( Boolean.FALSE ); isNullables.add( Boolean.FALSE );
isLazies.add( Boolean.FALSE ); isLazies.add( Boolean.FALSE );
joinIter = persistentClass.getSubclassJoinClosureIterator(); for ( Join join : persistentClass.getSubclassJoinClosure() ) {
while ( joinIter.hasNext() ) {
Join join = joinIter.next();
isConcretes.add( persistentClass.isClassOrSuperclassTable( join.getTable() ) ); isConcretes.add( persistentClass.isClassOrSuperclassTable( join.getTable() ) );
isClassOrSuperclassJoins.add( persistentClass.isClassOrSuperclassJoin( join ) ); isClassOrSuperclassJoins.add( persistentClass.isClassOrSuperclassJoin( join ) );
isInverses.add( join.isInverse() ); isInverses.add( join.isInverse() );

View File

@ -182,9 +182,8 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
} }
HashSet<String> subclassTables = new HashSet<>(); HashSet<String> subclassTables = new HashSet<>();
Iterator<Table> subclassTableIter = persistentClass.getSubclassTableClosureIterator(); for ( Table table : persistentClass.getSubclassTableClosure() ) {
while ( subclassTableIter.hasNext() ) { subclassTables.add( determineTableName( table ) );
subclassTables.add( determineTableName( subclassTableIter.next() ) );
} }
subclassSpaces = ArrayHelper.toStringArray( subclassTables ); subclassSpaces = ArrayHelper.toStringArray( subclassTables );
@ -210,14 +209,12 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
int idColumnSpan = getIdentifierColumnSpan(); int idColumnSpan = getIdentifierColumnSpan();
ArrayList<String> tableNames = new ArrayList<>(); ArrayList<String> tableNames = new ArrayList<>();
ArrayList<String[]> keyColumns = new ArrayList<>(); ArrayList<String[]> keyColumns = new ArrayList<>();
Iterator<Table> tableIter = persistentClass.getSubclassTableClosureIterator(); for ( Table table : persistentClass.getSubclassTableClosure() ) {
while ( tableIter.hasNext() ) { if ( !table.isAbstractUnionTable() ) {
Table tab = tableIter.next(); final String tableName = determineTableName( table );
if ( !tab.isAbstractUnionTable() ) {
final String tableName = determineTableName( tab );
tableNames.add( tableName ); tableNames.add( tableName );
String[] key = new String[idColumnSpan]; String[] key = new String[idColumnSpan];
List<Column> columns = tab.getPrimaryKey().getColumns(); List<Column> columns = table.getPrimaryKey().getColumns();
for ( int k = 0; k < idColumnSpan; k++ ) { for ( int k = 0; k < idColumnSpan; k++ ) {
key[k] = columns.get(k).getQuotedName( factory.getJdbcServices().getDialect() ); key[k] = columns.get(k).getQuotedName( factory.getJdbcServices().getDialect() );
} }
@ -468,14 +465,10 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
); );
} }
HashSet<Column> columns = new LinkedHashSet<>(); Set<Column> columns = new LinkedHashSet<>();
Iterator<Table> titer = model.getSubclassTableClosureIterator(); for ( Table table : model.getSubclassTableClosure() ) {
while ( titer.hasNext() ) {
Table table = titer.next();
if ( !table.isAbstractUnionTable() ) { if ( !table.isAbstractUnionTable() ) {
for ( Column column : table.getColumns() ) { columns.addAll( table.getColumns() );
columns.add( column );
}
} }
} }

View File

@ -28,9 +28,9 @@ public class DynamicMapInstantiator implements Instantiator {
this.roleName = mappingInfo.getEntityName(); this.roleName = mappingInfo.getEntityName();
isInstanceEntityNames.add( roleName ); isInstanceEntityNames.add( roleName );
if ( mappingInfo.hasSubclasses() ) { if ( mappingInfo.hasSubclasses() ) {
Iterator itr = mappingInfo.getSubclassClosureIterator(); Iterator<PersistentClass> itr = mappingInfo.getSubclassClosureIterator();
while ( itr.hasNext() ) { while ( itr.hasNext() ) {
final PersistentClass subclassInfo = ( PersistentClass ) itr.next(); final PersistentClass subclassInfo = itr.next();
isInstanceEntityNames.add( subclassInfo.getEntityName() ); isInstanceEntityNames.add( subclassInfo.getEntityName() );
} }
} }