get rid of the last iterators in the mapping package
This commit is contained in:
parent
12a515a95a
commit
09299e1f41
|
@ -1872,16 +1872,14 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector
|
|||
final MetadataBuildingContext buildingContext) throws MappingException {
|
||||
table.createForeignKeys();
|
||||
|
||||
Iterator itr = table.getForeignKeyIterator();
|
||||
while ( itr.hasNext() ) {
|
||||
final ForeignKey fk = (ForeignKey) itr.next();
|
||||
if ( !done.contains( fk ) ) {
|
||||
done.add( fk );
|
||||
final String referencedEntityName = fk.getReferencedEntityName();
|
||||
for ( ForeignKey foreignKey : table.getForeignKeys().values() ) {
|
||||
if ( !done.contains( foreignKey ) ) {
|
||||
done.add( foreignKey );
|
||||
final String referencedEntityName = foreignKey.getReferencedEntityName();
|
||||
if ( referencedEntityName == null ) {
|
||||
throw new MappingException(
|
||||
"An association from the table " +
|
||||
fk.getTable().getName() +
|
||||
foreignKey.getTable().getName() +
|
||||
" does not specify the referenced entity"
|
||||
);
|
||||
}
|
||||
|
@ -1891,7 +1889,7 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector
|
|||
if ( referencedClass == null ) {
|
||||
throw new MappingException(
|
||||
"An association from the table " +
|
||||
fk.getTable().getName() +
|
||||
foreignKey.getTable().getName() +
|
||||
" refers to an unmapped class: " +
|
||||
referencedEntityName
|
||||
);
|
||||
|
@ -1900,12 +1898,12 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector
|
|||
secondPassCompileForeignKeys( referencedClass.getSuperclass().getTable(), done, buildingContext );
|
||||
}
|
||||
|
||||
fk.setReferencedTable( referencedClass.getTable() );
|
||||
foreignKey.setReferencedTable( referencedClass.getTable() );
|
||||
|
||||
Identifier nameIdentifier;
|
||||
|
||||
ImplicitForeignKeyNameSource foreignKeyNameSource = new ImplicitForeignKeyNameSource() {
|
||||
final List<Identifier> columnNames = extractColumnNames( fk.getColumns() );
|
||||
final List<Identifier> columnNames = extractColumnNames( foreignKey.getColumns() );
|
||||
List<Identifier> referencedColumnNames = null;
|
||||
|
||||
@Override
|
||||
|
@ -1920,20 +1918,20 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector
|
|||
|
||||
@Override
|
||||
public Identifier getReferencedTableName() {
|
||||
return fk.getReferencedTable().getNameIdentifier();
|
||||
return foreignKey.getReferencedTable().getNameIdentifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Identifier> getReferencedColumnNames() {
|
||||
if ( referencedColumnNames == null ) {
|
||||
referencedColumnNames = extractColumnNames( fk.getReferencedColumns() );
|
||||
referencedColumnNames = extractColumnNames( foreignKey.getReferencedColumns() );
|
||||
}
|
||||
return referencedColumnNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getUserProvidedIdentifier() {
|
||||
return fk.getName() != null ? Identifier.toIdentifier( fk.getName() ) : null;
|
||||
return foreignKey.getName() != null ? Identifier.toIdentifier( foreignKey.getName() ) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1944,9 +1942,9 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector
|
|||
|
||||
nameIdentifier = getMetadataBuildingOptions().getImplicitNamingStrategy().determineForeignKeyName(foreignKeyNameSource);
|
||||
|
||||
fk.setName( nameIdentifier.render( getDatabase().getJdbcEnvironment().getDialect() ) );
|
||||
foreignKey.setName( nameIdentifier.render( getDatabase().getJdbcEnvironment().getDialect() ) );
|
||||
|
||||
fk.alignColumns();
|
||||
foreignKey.alignColumns();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1814,19 +1814,19 @@ public class ModelBinder {
|
|||
secondaryTableJoin.createForeignKey();
|
||||
}
|
||||
}
|
||||
|
||||
private List<ColumnSource> sortColumns(List<ColumnSource> primaryKeyColumnSources, KeyValue identifier) {
|
||||
if ( primaryKeyColumnSources.size() == 1 || !identifier.getType().isComponentType() ) {
|
||||
return primaryKeyColumnSources;
|
||||
}
|
||||
final ComponentType componentType = (ComponentType) identifier.getType();
|
||||
final List<ColumnSource> sortedColumnSource = new ArrayList<>( primaryKeyColumnSources.size() );
|
||||
final int[] originalPropertyOrder = componentType.getOriginalPropertyOrder();
|
||||
for ( int originalIndex : originalPropertyOrder ) {
|
||||
sortedColumnSource.add( primaryKeyColumnSources.get( originalIndex ) );
|
||||
}
|
||||
return sortedColumnSource;
|
||||
}
|
||||
//
|
||||
// private List<ColumnSource> sortColumns(List<ColumnSource> primaryKeyColumnSources, KeyValue identifier) {
|
||||
// if ( primaryKeyColumnSources.size() == 1 || !identifier.getType().isComponentType() ) {
|
||||
// return primaryKeyColumnSources;
|
||||
// }
|
||||
// final ComponentType componentType = (ComponentType) identifier.getType();
|
||||
// final List<ColumnSource> sortedColumnSource = new ArrayList<>( primaryKeyColumnSources.size() );
|
||||
// final int[] originalPropertyOrder = componentType.getOriginalPropertyOrder();
|
||||
// for ( int originalIndex : originalPropertyOrder ) {
|
||||
// sortedColumnSource.add( primaryKeyColumnSources.get( originalIndex ) );
|
||||
// }
|
||||
// return sortedColumnSource;
|
||||
// }
|
||||
|
||||
private Property createEmbeddedAttribute(
|
||||
MappingDocument sourceDocument,
|
||||
|
@ -3168,7 +3168,7 @@ public class ModelBinder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void doSecondPass(Map persistentClasses) throws org.hibernate.MappingException {
|
||||
public void doSecondPass(Map<String, PersistentClass> persistentClasses) throws org.hibernate.MappingException {
|
||||
bindCollectionTable();
|
||||
|
||||
bindCollectionKey();
|
||||
|
@ -4108,7 +4108,7 @@ public class ModelBinder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void doSecondPass(Map persistentClasses) throws org.hibernate.MappingException {
|
||||
public void doSecondPass(Map<String, PersistentClass> persistentClasses) throws org.hibernate.MappingException {
|
||||
if ( allColumnsNamed ) {
|
||||
relationalObjectBinder.bindColumnsAndFormulas(
|
||||
mappingDocument,
|
||||
|
@ -4202,7 +4202,7 @@ public class ModelBinder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void doSecondPass(Map persistentClasses) throws org.hibernate.MappingException {
|
||||
public void doSecondPass(Map<String, PersistentClass> persistentClasses) throws org.hibernate.MappingException {
|
||||
if ( referencedEntityAttributeName == null ) {
|
||||
manyToOneBinding.createForeignKey();
|
||||
}
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
*/
|
||||
package org.hibernate.cache.cfg.internal;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.hibernate.cache.cfg.spi.NaturalIdDataCachingConfig;
|
||||
import org.hibernate.cache.spi.access.AccessType;
|
||||
import org.hibernate.mapping.Property;
|
||||
|
@ -36,10 +34,8 @@ public class NaturalIdDataCachingConfigImpl
|
|||
}
|
||||
|
||||
private boolean hasAnyMutableNaturalIdProps() {
|
||||
final Iterator itr = rootEntityDescriptor.getDeclaredPropertyIterator();
|
||||
while ( itr.hasNext() ) {
|
||||
final Property prop = (Property) itr.next();
|
||||
if ( prop.isNaturalIdentifier() && prop.isUpdateable() ) {
|
||||
for ( Property property : rootEntityDescriptor.getDeclaredProperties() ) {
|
||||
if ( property.isNaturalIdentifier() && property.isUpdateable() ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1617,12 +1617,8 @@ public final class AnnotationBinder {
|
|||
reflectionManager, entityClass, callbackType ) );
|
||||
}
|
||||
|
||||
context.getMetadataCollector().addSecondPass( new SecondPass() {
|
||||
@Override
|
||||
public void doSecondPass(Map persistentClasses) throws MappingException {
|
||||
for ( @SuppressWarnings("unchecked") Iterator<Property> propertyIterator = persistentClass.getDeclaredPropertyIterator();
|
||||
propertyIterator.hasNext(); ) {
|
||||
Property property = propertyIterator.next();
|
||||
context.getMetadataCollector().addSecondPass( persistentClasses -> {
|
||||
for ( Property property : persistentClass.getDeclaredProperties() ) {
|
||||
if ( property.isComposite() ) {
|
||||
for ( CallbackType callbackType : CallbackType.values() ) {
|
||||
property.addCallbackDefinitions( CallbackDefinitionResolverLegacyImpl.resolveEmbeddableCallbacks(
|
||||
|
@ -1630,7 +1626,6 @@ public final class AnnotationBinder {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.hibernate.internal.CoreMessageLogger;
|
|||
import org.hibernate.mapping.Collection;
|
||||
import org.hibernate.mapping.IndexedCollection;
|
||||
import org.hibernate.mapping.OneToMany;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.Selectable;
|
||||
import org.hibernate.mapping.Value;
|
||||
|
||||
|
@ -44,7 +45,7 @@ public abstract class CollectionSecondPass implements SecondPass {
|
|||
this( buildingContext, collection, Collections.EMPTY_MAP );
|
||||
}
|
||||
|
||||
public void doSecondPass(Map persistentClasses)
|
||||
public void doSecondPass(Map<String, PersistentClass> persistentClasses)
|
||||
throws MappingException {
|
||||
if ( LOG.isDebugEnabled() ) {
|
||||
LOG.debugf( "Second pass for collection: %s", collection.getRole() );
|
||||
|
|
|
@ -63,8 +63,8 @@ public class CopyIdentifierComponentSecondPass extends FkSecondPass {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void doSecondPass(Map persistentClasses) throws MappingException {
|
||||
PersistentClass referencedPersistentClass = (PersistentClass) persistentClasses.get( referencedEntityName );
|
||||
public void doSecondPass(Map<String, PersistentClass> persistentClasses) throws MappingException {
|
||||
PersistentClass referencedPersistentClass = persistentClasses.get( referencedEntityName );
|
||||
// TODO better error names
|
||||
if ( referencedPersistentClass == null ) {
|
||||
throw new AnnotationException( "Unknown entity name: " + referencedEntityName );
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.Map;
|
|||
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.mapping.JoinedSubclass;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.RootClass;
|
||||
|
||||
/**
|
||||
|
@ -26,7 +27,7 @@ public class CreateKeySecondPass implements SecondPass {
|
|||
this.joinedSubClass = joinedSubClass;
|
||||
}
|
||||
|
||||
public void doSecondPass(Map persistentClasses) throws MappingException {
|
||||
public void doSecondPass(Map<String, PersistentClass> persistentClasses) throws MappingException {
|
||||
if ( rootClass != null ) {
|
||||
rootClass.createPrimaryKey();
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.hibernate.MappingException;
|
|||
import org.hibernate.annotations.common.reflection.XProperty;
|
||||
import org.hibernate.boot.model.IdentifierGeneratorDefinition;
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.SimpleValue;
|
||||
|
||||
/**
|
||||
|
@ -50,7 +51,7 @@ public class IdGeneratorResolverSecondPass implements SecondPass {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void doSecondPass(Map idGeneratorDefinitionMap) throws MappingException {
|
||||
public void doSecondPass(Map<String, PersistentClass> idGeneratorDefinitionMap) throws MappingException {
|
||||
BinderHelper.makeIdGenerator( id, idXProperty, generatorType, generatorName, buildingContext, localIdentifierGeneratorDefinition );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.hibernate.MappingException;
|
|||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.cfg.annotations.TableBinder;
|
||||
import org.hibernate.mapping.JoinedSubclass;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.SimpleValue;
|
||||
|
||||
/**
|
||||
|
@ -39,7 +40,7 @@ public class JoinedSubclassFkSecondPass extends FkSecondPass {
|
|||
return true;
|
||||
}
|
||||
|
||||
public void doSecondPass(Map persistentClasses) throws MappingException {
|
||||
public void doSecondPass(Map<String, PersistentClass> persistentClasses) throws MappingException {
|
||||
TableBinder.bindFk( entity.getSuperclass(), entity, columns, value, false, buildingContext );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ public class OneToOneSecondPass implements SecondPass {
|
|||
}
|
||||
|
||||
//TODO refactor this code, there is a lot of duplication in this method
|
||||
public void doSecondPass(Map persistentClasses) throws MappingException {
|
||||
public void doSecondPass(Map<String, PersistentClass> persistentClasses) throws MappingException {
|
||||
OneToOne value = new OneToOne(
|
||||
buildingContext,
|
||||
propertyHolder.getTable(),
|
||||
|
@ -141,14 +141,13 @@ public class OneToOneSecondPass implements SecondPass {
|
|||
//no column associated since its a one to one
|
||||
propertyHolder.addProperty( prop, inferredData.getDeclaringClass() );
|
||||
}
|
||||
else {
|
||||
// else {
|
||||
//this is a many to one with Formula
|
||||
|
||||
}
|
||||
// }
|
||||
}
|
||||
else {
|
||||
value.setMappedByProperty( mappedBy );
|
||||
PersistentClass otherSide = (PersistentClass) persistentClasses.get( value.getReferencedEntityName() );
|
||||
PersistentClass otherSide = persistentClasses.get( value.getReferencedEntityName() );
|
||||
Property otherSideProperty;
|
||||
try {
|
||||
if ( otherSide == null ) {
|
||||
|
|
|
@ -41,8 +41,8 @@ public class PkDrivenByDefaultMapsIdSecondPass extends FkSecondPass {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void doSecondPass(Map persistentClasses) throws MappingException {
|
||||
PersistentClass referencedEntity = (PersistentClass) persistentClasses.get( referencedEntityName );
|
||||
public void doSecondPass(Map<String, PersistentClass> persistentClasses) throws MappingException {
|
||||
PersistentClass referencedEntity = persistentClasses.get( referencedEntityName );
|
||||
if ( referencedEntity == null ) {
|
||||
throw new AnnotationException(
|
||||
"Unknown entity name: " + referencedEntityName
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.cfg;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.annotations.common.reflection.XClass;
|
||||
|
@ -45,7 +46,7 @@ public final class PropertyHolderBuilder {
|
|||
*
|
||||
* @param component component to wrap
|
||||
* @param path component path
|
||||
* @param context
|
||||
*
|
||||
* @return PropertyHolder
|
||||
*/
|
||||
public static PropertyHolder buildPropertyHolder(
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.cfg;
|
||||
|
||||
import jakarta.persistence.Access;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
|
|
|
@ -5,19 +5,21 @@
|
|||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.cfg;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.annotations.common.reflection.XAnnotatedElement;
|
||||
import org.hibernate.cfg.annotations.EntityBinder;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
public class SecondaryTableSecondPass implements SecondPass {
|
||||
private EntityBinder entityBinder;
|
||||
private PropertyHolder propertyHolder;
|
||||
private XAnnotatedElement annotatedClass;
|
||||
private final EntityBinder entityBinder;
|
||||
private final PropertyHolder propertyHolder;
|
||||
private final XAnnotatedElement annotatedClass;
|
||||
|
||||
public SecondaryTableSecondPass(EntityBinder entityBinder, PropertyHolder propertyHolder, XAnnotatedElement annotatedClass) {
|
||||
this.entityBinder = entityBinder;
|
||||
|
@ -25,7 +27,7 @@ public class SecondaryTableSecondPass implements SecondPass {
|
|||
this.annotatedClass = annotatedClass;
|
||||
}
|
||||
|
||||
public void doSecondPass(Map persistentClasses) throws MappingException {
|
||||
public void doSecondPass(Map<String, PersistentClass> persistentClasses) throws MappingException {
|
||||
entityBinder.finalSecondaryTableBinding( propertyHolder );
|
||||
|
||||
}
|
||||
|
|
|
@ -10,18 +10,19 @@ import java.util.Map;
|
|||
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.cfg.annotations.BasicValueBinder;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
|
||||
/**
|
||||
* @author Sharath Reddy
|
||||
*/
|
||||
public class SetBasicValueTypeSecondPass implements SecondPass {
|
||||
private final BasicValueBinder binder;
|
||||
private final BasicValueBinder<?> binder;
|
||||
|
||||
public SetBasicValueTypeSecondPass(BasicValueBinder val) {
|
||||
public SetBasicValueTypeSecondPass(BasicValueBinder<?> val) {
|
||||
binder = val;
|
||||
}
|
||||
|
||||
public void doSecondPass(Map persistentClasses) throws MappingException {
|
||||
public void doSecondPass(Map<String, PersistentClass> persistentClasses) throws MappingException {
|
||||
binder.fillSimpleValue();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
package org.hibernate.cfg;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.ToOne;
|
||||
|
||||
/**
|
||||
|
@ -30,7 +31,7 @@ public class SimpleToOneFkSecondPass extends FkSecondPass {
|
|||
return false;
|
||||
}
|
||||
|
||||
public void doSecondPass(java.util.Map persistentClasses) throws MappingException {
|
||||
public void doSecondPass(java.util.Map<String, PersistentClass> persistentClasses) throws MappingException {
|
||||
value.createForeignKey();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
*/
|
||||
package org.hibernate.cfg;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.hibernate.AnnotationException;
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.MappingException;
|
||||
|
@ -88,10 +86,10 @@ public class ToOneFkSecondPass extends FkSecondPass {
|
|||
return false;
|
||||
}
|
||||
|
||||
public void doSecondPass(java.util.Map persistentClasses) throws MappingException {
|
||||
public void doSecondPass(java.util.Map<String, PersistentClass> persistentClasses) throws MappingException {
|
||||
if ( value instanceof ManyToOne ) {
|
||||
ManyToOne manyToOne = (ManyToOne) value;
|
||||
PersistentClass ref = (PersistentClass) persistentClasses.get( manyToOne.getReferencedEntityName() );
|
||||
PersistentClass ref = persistentClasses.get( manyToOne.getReferencedEntityName() );
|
||||
if ( ref == null ) {
|
||||
throw new AnnotationException(
|
||||
"@OneToOne or @ManyToOne on "
|
||||
|
|
|
@ -18,9 +18,9 @@ import org.hibernate.mapping.PersistentClass;
|
|||
* @author Hardy Ferentschik
|
||||
*/
|
||||
public class VerifyFetchProfileReferenceSecondPass implements SecondPass {
|
||||
private String fetchProfileName;
|
||||
private FetchProfile.FetchOverride fetch;
|
||||
private MetadataBuildingContext buildingContext;
|
||||
private final String fetchProfileName;
|
||||
private final FetchProfile.FetchOverride fetch;
|
||||
private final MetadataBuildingContext buildingContext;
|
||||
|
||||
public VerifyFetchProfileReferenceSecondPass(
|
||||
String fetchProfileName,
|
||||
|
@ -31,7 +31,7 @@ public class VerifyFetchProfileReferenceSecondPass implements SecondPass {
|
|||
this.buildingContext = buildingContext;
|
||||
}
|
||||
|
||||
public void doSecondPass(Map persistentClasses) throws MappingException {
|
||||
public void doSecondPass(Map<String, PersistentClass> persistentClasses) throws MappingException {
|
||||
org.hibernate.mapping.FetchProfile profile = buildingContext.getMetadataCollector().getFetchProfile(
|
||||
fetchProfileName
|
||||
);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
package org.hibernate.cfg.annotations;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
@ -129,7 +129,7 @@ public class MapBinder extends CollectionBinder {
|
|||
// check if the index column has been mapped by the associated entity to a property;
|
||||
// @MapKeyColumn only maps a column to the primary table for the one-to-many, so we only
|
||||
// need to check "un-joined" properties.
|
||||
if ( !propertyIteratorContainsColumn( persistentClass.getUnjoinedPropertyIterator(), column ) ) {
|
||||
if ( !propertiesContainColumn( persistentClass.getUnjoinedProperties(), column ) ) {
|
||||
// The index column is not mapped to an associated entity property so we can
|
||||
// safely make the index column nullable.
|
||||
column.setNullable( true );
|
||||
|
@ -138,9 +138,8 @@ public class MapBinder extends CollectionBinder {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean propertyIteratorContainsColumn(Iterator<Property> propertyIterator, Column column) {
|
||||
for (; propertyIterator.hasNext(); ) {
|
||||
final Property property = propertyIterator.next();
|
||||
private boolean propertiesContainColumn(List<Property> properties, Column column) {
|
||||
for ( Property property : properties ) {
|
||||
for ( Selectable selectable: property.getSelectables() ) {
|
||||
if ( column.equals( selectable ) ) {
|
||||
final Column iteratedColumn = (Column) selectable;
|
||||
|
|
|
@ -6,29 +6,20 @@
|
|||
*/
|
||||
package org.hibernate.cfg.annotations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import jakarta.persistence.SqlResultSetMapping;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.cfg.QuerySecondPass;
|
||||
import org.hibernate.internal.CoreLogging;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.Property;
|
||||
import org.hibernate.mapping.ToOne;
|
||||
import org.hibernate.mapping.Value;
|
||||
import org.hibernate.boot.query.SqlResultSetMappingDescriptor;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
public class ResultsetMappingSecondPass implements QuerySecondPass {
|
||||
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( ResultsetMappingSecondPass.class );
|
||||
// private static final CoreMessageLogger LOG = CoreLogging.messageLogger( ResultsetMappingSecondPass.class );
|
||||
|
||||
private final SqlResultSetMapping ann;
|
||||
private final MetadataBuildingContext context;
|
||||
|
@ -41,7 +32,7 @@ public class ResultsetMappingSecondPass implements QuerySecondPass {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void doSecondPass(Map persistentClasses) throws MappingException {
|
||||
public void doSecondPass(Map<String, PersistentClass> persistentClasses) throws MappingException {
|
||||
if ( ann == null ) {
|
||||
return;
|
||||
}
|
||||
|
@ -196,26 +187,26 @@ public class ResultsetMappingSecondPass implements QuerySecondPass {
|
|||
// context.getMetadataCollector().addResultSetMapping( definition );
|
||||
// }
|
||||
}
|
||||
|
||||
private String normalizeColumnQuoting(String name) {
|
||||
return context.getMetadataCollector().getDatabase().toIdentifier( name ).render();
|
||||
}
|
||||
|
||||
private List<String> getFollowers(Iterator parentPropIter, String reducedName, String name) {
|
||||
boolean hasFollowers = false;
|
||||
List<String> followers = new ArrayList<>();
|
||||
while ( parentPropIter.hasNext() ) {
|
||||
String currentPropertyName = ( (Property) parentPropIter.next() ).getName();
|
||||
String currentName = reducedName + '.' + currentPropertyName;
|
||||
if ( hasFollowers ) {
|
||||
followers.add( currentName );
|
||||
}
|
||||
if ( name.equals( currentName ) ) {
|
||||
hasFollowers = true;
|
||||
}
|
||||
}
|
||||
return followers;
|
||||
}
|
||||
//
|
||||
// private String normalizeColumnQuoting(String name) {
|
||||
// return context.getMetadataCollector().getDatabase().toIdentifier( name ).render();
|
||||
// }
|
||||
//
|
||||
// private List<String> getFollowers(Iterator<Property> parentPropIter, String reducedName, String name) {
|
||||
// boolean hasFollowers = false;
|
||||
// List<String> followers = new ArrayList<>();
|
||||
// while ( parentPropIter.hasNext() ) {
|
||||
// String currentPropertyName = parentPropIter.next().getName();
|
||||
// String currentName = reducedName + '.' + currentPropertyName;
|
||||
// if ( hasFollowers ) {
|
||||
// followers.add( currentName );
|
||||
// }
|
||||
// if ( name.equals( currentName ) ) {
|
||||
// hasFollowers = true;
|
||||
// }
|
||||
// }
|
||||
// return followers;
|
||||
// }
|
||||
//
|
||||
// private Iterator getSubPropertyIterator(PersistentClass pc, String reducedName) {
|
||||
// Value value = pc.getRecursiveProperty( reducedName ).getValue();
|
||||
|
|
|
@ -24,9 +24,8 @@ public class NullableDiscriminatorColumnSecondPass implements SecondPass {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void doSecondPass(Map persistentClasses) throws MappingException {
|
||||
PersistentClass rootPersistenceClass = (PersistentClass) persistentClasses.get( rootEntityName );
|
||||
public void doSecondPass(Map<String, PersistentClass> persistentClasses) throws MappingException {
|
||||
PersistentClass rootPersistenceClass = persistentClasses.get( rootEntityName );
|
||||
if ( hasNullDiscriminatorValue( rootPersistenceClass ) ) {
|
||||
for ( Selectable selectable: rootPersistenceClass.getDiscriminator().getSelectables() ) {
|
||||
if ( selectable instanceof Column ) {
|
||||
|
@ -40,9 +39,8 @@ public class NullableDiscriminatorColumnSecondPass implements SecondPass {
|
|||
if ( rootPersistenceClass.isDiscriminatorValueNull() ) {
|
||||
return true;
|
||||
}
|
||||
Iterator<Subclass> subclassIterator = rootPersistenceClass.getSubclassIterator();
|
||||
while ( subclassIterator.hasNext() ) {
|
||||
if ( subclassIterator.next().isDiscriminatorValueNull() ) {
|
||||
for ( Subclass subclass : rootPersistenceClass.getSubclasses() ) {
|
||||
if ( subclass.isDiscriminatorValueNull() ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,10 +56,7 @@ class SpannerDialectTableExporter implements Exporter<Table> {
|
|||
}
|
||||
else if ( table.getForeignKeys().size() > 0 ) {
|
||||
// a table with no PK's but has FK's; often corresponds to element collection properties
|
||||
keyColumns = new ArrayList<>();
|
||||
for (Iterator<Column> column = table.getColumnIterator(); column.hasNext();) {
|
||||
keyColumns.add( column.next() );
|
||||
}
|
||||
keyColumns = table.getColumns();
|
||||
}
|
||||
else {
|
||||
// the case corresponding to a sequence-table that will only have 1 row.
|
||||
|
@ -77,12 +74,11 @@ class SpannerDialectTableExporter implements Exporter<Table> {
|
|||
StringJoiner colsAndTypes = new StringJoiner( "," );
|
||||
|
||||
|
||||
for (Iterator<Column> column = table.getColumnIterator(); column.hasNext();) {
|
||||
Column col = column.next();
|
||||
for ( Column column : table.getColumns() ) {
|
||||
String columnDeclaration =
|
||||
col.getName()
|
||||
+ " " + col.getSqlType()
|
||||
+ ( col.isNullable() ? this.spannerDialect.getNullColumnString( col.getSqlType() ) : " not null" );
|
||||
column.getName()
|
||||
+ " " + column.getSqlType()
|
||||
+ ( column.isNullable() ? this.spannerDialect.getNullColumnString( column.getSqlType() ) : " not null" );
|
||||
colsAndTypes.add( columnDeclaration );
|
||||
}
|
||||
|
||||
|
|
|
@ -48,10 +48,10 @@ public interface UniqueDelegate {
|
|||
String getColumnDefinitionUniquenessFragment(Column column, SqlStringGenerationContext context);
|
||||
|
||||
/**
|
||||
* Get the fragment that can be used to apply unique constraints as part of table creation. The implementation
|
||||
* should iterate over the {@link UniqueKey} instances for the given table (see
|
||||
* {@link org.hibernate.mapping.Table#getUniqueKeyIterator()} and generate the whole fragment for all
|
||||
* unique keys
|
||||
* Get the fragment that can be used to apply unique constraints as part of table creation. The
|
||||
* implementation should iterate over the {@link UniqueKey} instances for the given table (see
|
||||
* {@link org.hibernate.mapping.Table#getUniqueKeyIterator()} and generate the whole fragment for
|
||||
* all unique keys
|
||||
* <p/>
|
||||
* Intended for Dialects which support unique constraint definitions, but just not in separate ALTER statements.
|
||||
*
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.function.Consumer;
|
|||
public final class IdentityMap<K,V> implements Map<K,V> {
|
||||
|
||||
private final LinkedHashMap<IdentityKey<K>,V> map;
|
||||
@SuppressWarnings( {"unchecked"})
|
||||
|
||||
private transient Entry<IdentityKey<K>,V>[] entryArray = null;
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,11 +13,9 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
||||
import org.hibernate.boot.spi.SessionFactoryOptions;
|
||||
import org.hibernate.jpa.event.spi.Callback;
|
||||
import org.hibernate.jpa.event.spi.CallbackDefinition;
|
||||
import org.hibernate.jpa.event.spi.CallbackType;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.Property;
|
||||
import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
|
||||
|
@ -68,9 +66,7 @@ public final class CallbacksFactory {
|
|||
registry.registerCallbacks( persistentClass.getMappedClass(),
|
||||
buildCallbacks( persistentClass.getCallbackDefinitions(), beanRegistry ) );
|
||||
|
||||
for ( @SuppressWarnings("unchecked") Iterator<Property> propertyIterator = persistentClass.getDeclaredPropertyIterator();
|
||||
propertyIterator.hasNext(); ) {
|
||||
final Property property = propertyIterator.next();
|
||||
for ( Property property : persistentClass.getDeclaredProperties() ) {
|
||||
registry.registerCallbacks( persistentClass.getMappedClass(),
|
||||
buildCallbacks( property.getCallbackDefinitions(), beanRegistry ) );
|
||||
}
|
||||
|
|
|
@ -67,7 +67,6 @@ import static org.hibernate.mapping.MappingHelper.injectParameters;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public class BasicValue extends SimpleValue implements JdbcTypeIndicators, Resolvable {
|
||||
private static final CoreMessageLogger log = CoreLogging.messageLogger( BasicValue.class );
|
||||
|
||||
|
@ -77,7 +76,7 @@ public class BasicValue extends SimpleValue implements JdbcTypeIndicators, Resol
|
|||
// incoming "configuration" values
|
||||
|
||||
private String explicitTypeName;
|
||||
private Map explicitLocalTypeParams;
|
||||
private Map<Object,Object> explicitLocalTypeParams;
|
||||
|
||||
private Function<TypeConfiguration, BasicJavaType> explicitJavaTypeAccess;
|
||||
private Function<TypeConfiguration, JdbcType> explicitJdbcTypeAccess;
|
||||
|
@ -179,7 +178,7 @@ public class BasicValue extends SimpleValue implements JdbcTypeIndicators, Resol
|
|||
@Override
|
||||
public long getColumnLength() {
|
||||
final Selectable column = getColumn();
|
||||
if ( column != null && column instanceof Column ) {
|
||||
if ( column instanceof Column ) {
|
||||
final Long length = ( (Column) column ).getLength();
|
||||
return length == null ? NO_COLUMN_LENGTH : length;
|
||||
}
|
||||
|
@ -191,7 +190,7 @@ public class BasicValue extends SimpleValue implements JdbcTypeIndicators, Resol
|
|||
@Override
|
||||
public int getColumnPrecision() {
|
||||
final Selectable column = getColumn();
|
||||
if ( column != null && column instanceof Column ) {
|
||||
if ( column instanceof Column ) {
|
||||
final Integer length = ( (Column) column ).getPrecision();
|
||||
return length == null ? NO_COLUMN_PRECISION : length;
|
||||
}
|
||||
|
@ -203,7 +202,7 @@ public class BasicValue extends SimpleValue implements JdbcTypeIndicators, Resol
|
|||
@Override
|
||||
public int getColumnScale() {
|
||||
final Selectable column = getColumn();
|
||||
if ( column != null && column instanceof Column ) {
|
||||
if ( column instanceof Column ) {
|
||||
final Integer length = ( (Column) column ).getScale();
|
||||
return length == null ? NO_COLUMN_SCALE : length;
|
||||
}
|
||||
|
@ -240,14 +239,12 @@ public class BasicValue extends SimpleValue implements JdbcTypeIndicators, Resol
|
|||
return;
|
||||
}
|
||||
|
||||
if ( column != null ) {
|
||||
throw new IllegalStateException(
|
||||
"BasicValue [" + ownerName + "." + propertyName +
|
||||
"] already had column associated: `" + column.getText() +
|
||||
"` -> `" + incomingColumn.getText() + "`"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addColumn(Column incomingColumn, boolean isInsertable, boolean isUpdatable) {
|
||||
|
@ -386,12 +383,12 @@ public class BasicValue extends SimpleValue implements JdbcTypeIndicators, Resol
|
|||
);
|
||||
}
|
||||
|
||||
JavaType jtd = null;
|
||||
JavaType<?> jtd = null;
|
||||
|
||||
// determine JavaType if we can
|
||||
|
||||
if ( explicitJavaTypeAccess != null ) {
|
||||
final BasicJavaType explicitJtd = explicitJavaTypeAccess.apply( typeConfiguration );
|
||||
final BasicJavaType<?> explicitJtd = explicitJavaTypeAccess.apply( typeConfiguration );
|
||||
if ( explicitJtd != null ) {
|
||||
jtd = explicitJtd;
|
||||
}
|
||||
|
@ -407,7 +404,7 @@ public class BasicValue extends SimpleValue implements JdbcTypeIndicators, Resol
|
|||
}
|
||||
|
||||
if ( jtd == null ) {
|
||||
final JavaType reflectedJtd = determineReflectedJavaType();
|
||||
final JavaType<?> reflectedJtd = determineReflectedJavaType();
|
||||
if ( reflectedJtd != null ) {
|
||||
jtd = reflectedJtd;
|
||||
}
|
||||
|
@ -453,7 +450,7 @@ public class BasicValue extends SimpleValue implements JdbcTypeIndicators, Resol
|
|||
|
||||
}
|
||||
|
||||
private JavaType determineReflectedJavaType() {
|
||||
private JavaType<?> determineReflectedJavaType() {
|
||||
final java.lang.reflect.Type impliedJavaType;
|
||||
|
||||
if ( resolvedJavaType != null ) {
|
||||
|
@ -486,8 +483,7 @@ public class BasicValue extends SimpleValue implements JdbcTypeIndicators, Resol
|
|||
}
|
||||
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
private static Resolution interpretExplicitlyNamedType(
|
||||
private static Resolution<?> interpretExplicitlyNamedType(
|
||||
String name,
|
||||
EnumType enumerationStyle,
|
||||
Function<TypeConfiguration, java.lang.reflect.Type> implicitJavaTypeAccess,
|
||||
|
@ -495,7 +491,7 @@ public class BasicValue extends SimpleValue implements JdbcTypeIndicators, Resol
|
|||
Function<TypeConfiguration, JdbcType> explicitStdAccess,
|
||||
Function<TypeConfiguration, MutabilityPlan> explicitMutabilityPlanAccess,
|
||||
ConverterDescriptor converterDescriptor,
|
||||
Map localTypeParams,
|
||||
Map<Object,Object> localTypeParams,
|
||||
Consumer<Properties> combinedParameterConsumer,
|
||||
JdbcTypeIndicators stdIndicators,
|
||||
TypeConfiguration typeConfiguration,
|
||||
|
@ -539,7 +535,7 @@ public class BasicValue extends SimpleValue implements JdbcTypeIndicators, Resol
|
|||
if ( name.startsWith( BasicTypeImpl.EXTERNALIZED_PREFIX ) ) {
|
||||
final BasicTypeImpl<Object> basicType = context.getBootstrapContext().resolveAdHocBasicType( name );
|
||||
|
||||
return new NamedBasicTypeResolution(
|
||||
return new NamedBasicTypeResolution<>(
|
||||
basicType.getJavaTypeDescriptor(),
|
||||
basicType,
|
||||
null,
|
||||
|
@ -549,24 +545,24 @@ public class BasicValue extends SimpleValue implements JdbcTypeIndicators, Resol
|
|||
}
|
||||
|
||||
// see if it is a named basic type
|
||||
final BasicType basicTypeByName = typeConfiguration.getBasicTypeRegistry().getRegisteredType( name );
|
||||
final BasicType<?> basicTypeByName = typeConfiguration.getBasicTypeRegistry().getRegisteredType( name );
|
||||
if ( basicTypeByName != null ) {
|
||||
final BasicValueConverter valueConverter;
|
||||
final BasicValueConverter<?,?> valueConverter;
|
||||
final JavaType<?> domainJtd;
|
||||
if ( converterDescriptor != null ) {
|
||||
valueConverter = converterDescriptor.createJpaAttributeConverter( converterCreationContext );
|
||||
domainJtd = valueConverter.getDomainJavaType();
|
||||
}
|
||||
else if ( basicTypeByName instanceof ConvertedBasicType ) {
|
||||
final ConvertedBasicType convertedType = (ConvertedBasicType) basicTypeByName;
|
||||
return new ConvertedBasicTypeResolution( convertedType, stdIndicators );
|
||||
final ConvertedBasicType<?> convertedType = (ConvertedBasicType<?>) basicTypeByName;
|
||||
return new ConvertedBasicTypeResolution<>( convertedType, stdIndicators );
|
||||
}
|
||||
else {
|
||||
valueConverter = null;
|
||||
domainJtd = basicTypeByName.getJavaTypeDescriptor();
|
||||
}
|
||||
|
||||
return new NamedBasicTypeResolution(
|
||||
return new NamedBasicTypeResolution<>(
|
||||
domainJtd,
|
||||
basicTypeByName,
|
||||
valueConverter,
|
||||
|
@ -594,7 +590,7 @@ public class BasicValue extends SimpleValue implements JdbcTypeIndicators, Resol
|
|||
// see if the name is a UserType or BasicType implementor class name
|
||||
final ClassLoaderService cls = typeConfiguration.getServiceRegistry().getService( ClassLoaderService.class );
|
||||
try {
|
||||
final Class typeNamedClass = cls.classForName( name );
|
||||
final Class<?> typeNamedClass = cls.classForName( name );
|
||||
|
||||
// if there are no local config params, register an implicit TypeDefinition for this custom type .
|
||||
// later uses may find it and re-use its cacheable reference...
|
||||
|
@ -670,7 +666,7 @@ public class BasicValue extends SimpleValue implements JdbcTypeIndicators, Resol
|
|||
return typeConfiguration;
|
||||
}
|
||||
|
||||
public void setExplicitTypeParams(Map explicitLocalTypeParams) {
|
||||
public void setExplicitTypeParams(Map<Object,Object> explicitLocalTypeParams) {
|
||||
this.explicitLocalTypeParams = explicitLocalTypeParams;
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,8 @@ public abstract class Constraint implements RelationalModel, Exportable, Seriali
|
|||
if ( o instanceof Column ) {
|
||||
defensive.add( (Column) o );
|
||||
}
|
||||
//else: others might be Formula instances. They don't need to be part of the name generation.
|
||||
// else: others might be Formula instances.
|
||||
// They don't need to be part of the name generation.
|
||||
}
|
||||
return generateName( prefix, table, defensive.toArray( new Column[0] ) );
|
||||
}
|
||||
|
@ -156,6 +157,7 @@ public abstract class Constraint implements RelationalModel, Exportable, Seriali
|
|||
return columns.get( i );
|
||||
}
|
||||
|
||||
@Deprecated(since = "6.0")
|
||||
public Iterator<Column> getColumnIterator() {
|
||||
return columns.iterator();
|
||||
}
|
||||
|
|
|
@ -60,19 +60,17 @@ public class DenormalizedTable extends Table {
|
|||
@Override
|
||||
public void createForeignKeys() {
|
||||
includedTable.createForeignKeys();
|
||||
Iterator<ForeignKey> iter = includedTable.getForeignKeyIterator();
|
||||
while ( iter.hasNext() ) {
|
||||
ForeignKey fk = iter.next();
|
||||
for ( ForeignKey foreignKey : includedTable.getForeignKeys().values() ) {
|
||||
createForeignKey(
|
||||
Constraint.generateName(
|
||||
fk.generatedConstraintNamePrefix(),
|
||||
foreignKey.generatedConstraintNamePrefix(),
|
||||
this,
|
||||
fk.getColumns()
|
||||
foreignKey.getColumns()
|
||||
),
|
||||
fk.getColumns(),
|
||||
fk.getReferencedEntityName(),
|
||||
fk.getKeyDefinition(),
|
||||
fk.getReferencedColumns()
|
||||
foreignKey.getColumns(),
|
||||
foreignKey.getReferencedEntityName(),
|
||||
foreignKey.getKeyDefinition(),
|
||||
foreignKey.getReferencedColumns()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -117,10 +115,8 @@ public class DenormalizedTable extends Table {
|
|||
@Override
|
||||
public Iterator<UniqueKey> getUniqueKeyIterator() {
|
||||
if ( !includedTable.isPhysicalTable() ) {
|
||||
Iterator<UniqueKey> iter = includedTable.getUniqueKeyIterator();
|
||||
while ( iter.hasNext() ) {
|
||||
UniqueKey uk = iter.next();
|
||||
createUniqueKey( uk.getColumns() );
|
||||
for ( UniqueKey uniqueKey : includedTable.getUniqueKeys().values() ) {
|
||||
createUniqueKey( uniqueKey.getColumns() );
|
||||
}
|
||||
}
|
||||
return getUniqueKeys().values().iterator();
|
||||
|
|
|
@ -65,20 +65,14 @@ public class ForeignKey extends Constraint {
|
|||
String[] columnNames = new String[getColumnSpan()];
|
||||
String[] referencedColumnNames = new String[getColumnSpan()];
|
||||
|
||||
final Iterator<Column> referencedColumnItr;
|
||||
if ( isReferenceToPrimaryKey() ) {
|
||||
referencedColumnItr = referencedTable.getPrimaryKey().getColumnIterator();
|
||||
}
|
||||
else {
|
||||
referencedColumnItr = referencedColumns.iterator();
|
||||
}
|
||||
final List<Column> referencedColumns = isReferenceToPrimaryKey()
|
||||
? referencedTable.getPrimaryKey().getColumns()
|
||||
: this.referencedColumns;
|
||||
|
||||
Iterator<Column> columnItr = getColumnIterator();
|
||||
int i = 0;
|
||||
while ( columnItr.hasNext() ) {
|
||||
columnNames[i] = columnItr.next().getQuotedName( dialect );
|
||||
referencedColumnNames[i] = referencedColumnItr.next().getQuotedName( dialect );
|
||||
i++;
|
||||
List<Column> columns = getColumns();
|
||||
for ( int i=0; i<referencedColumns.size() && i<columns.size(); i++ ) {
|
||||
columnNames[i] = columns.get(i).getQuotedName( dialect );
|
||||
referencedColumnNames[i] = referencedColumns.get(i).getQuotedName( dialect );
|
||||
}
|
||||
|
||||
final String result = keyDefinition != null ?
|
||||
|
@ -218,12 +212,11 @@ public class ForeignKey extends Constraint {
|
|||
return referencedColumns.isEmpty();
|
||||
}
|
||||
|
||||
public void addReferencedColumns(Iterator<Column> referencedColumnsIterator) {
|
||||
while ( referencedColumnsIterator.hasNext() ) {
|
||||
Selectable col = referencedColumnsIterator.next();
|
||||
if ( !col.isFormula() ) {
|
||||
addReferencedColumn( (Column) col );
|
||||
}
|
||||
public void addReferencedColumns(List<Column> referencedColumns) {
|
||||
for (Column referencedColumn : referencedColumns) {
|
||||
// if ( !referencedColumn.isFormula() ) {
|
||||
addReferencedColumn( referencedColumn );
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
*/
|
||||
package org.hibernate.mapping;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
|
@ -76,7 +75,7 @@ public abstract class IndexedCollection extends Collection {
|
|||
}
|
||||
getCollectionTable().setPrimaryKey(pk);
|
||||
}
|
||||
else {
|
||||
// else {
|
||||
// don't create a unique key, 'cos some
|
||||
// databases don't like a UK on nullable
|
||||
// columns
|
||||
|
@ -84,7 +83,7 @@ public abstract class IndexedCollection extends Collection {
|
|||
list.addAll( getKey().getConstraintColumns() );
|
||||
list.addAll( getIndex().getConstraintColumns() );
|
||||
getCollectionTable().createUniqueKey(list);*/
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
public void validate(Mapping mapping) throws MappingException {
|
||||
|
|
|
@ -7,12 +7,10 @@
|
|||
package org.hibernate.mapping;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.type.EntityType;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
|
@ -64,11 +62,11 @@ public class ManyToOne extends ToOne {
|
|||
}
|
||||
}
|
||||
|
||||
public void createPropertyRefConstraints(Map persistentClasses) {
|
||||
public void createPropertyRefConstraints(Map<String, PersistentClass> persistentClasses) {
|
||||
if (referencedPropertyName!=null) {
|
||||
// Ensure properties are sorted before we create a foreign key
|
||||
sortProperties();
|
||||
PersistentClass pc = (PersistentClass) persistentClasses.get(getReferencedEntityName() );
|
||||
PersistentClass pc = persistentClasses.get(getReferencedEntityName() );
|
||||
|
||||
Property property = pc.getReferencedProperty( getReferencedPropertyName() );
|
||||
|
||||
|
|
|
@ -30,8 +30,8 @@ import java.util.List;
|
|||
public class MappedSuperclass {
|
||||
private final MappedSuperclass superMappedSuperclass;
|
||||
private final PersistentClass superPersistentClass;
|
||||
private final List declaredProperties;
|
||||
private Class mappedClass;
|
||||
private final List<Property> declaredProperties;
|
||||
private Class<?> mappedClass;
|
||||
private Property identifierProperty;
|
||||
private Property version;
|
||||
private Component identifierMapper;
|
||||
|
@ -39,7 +39,7 @@ public class MappedSuperclass {
|
|||
public MappedSuperclass(MappedSuperclass superMappedSuperclass, PersistentClass superPersistentClass) {
|
||||
this.superMappedSuperclass = superMappedSuperclass;
|
||||
this.superPersistentClass = superPersistentClass;
|
||||
this.declaredProperties = new ArrayList();
|
||||
this.declaredProperties = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,28 +71,32 @@ public class MappedSuperclass {
|
|||
return superPersistentClass;
|
||||
}
|
||||
|
||||
public Iterator getDeclaredPropertyIterator() {
|
||||
@Deprecated(since = "6.0")
|
||||
public Iterator<Property> getDeclaredPropertyIterator() {
|
||||
return declaredProperties.iterator();
|
||||
}
|
||||
|
||||
public List<Property> getDeclaredProperties() {
|
||||
return declaredProperties;
|
||||
}
|
||||
|
||||
public void addDeclaredProperty(Property p) {
|
||||
//Do not add duplicate properties
|
||||
//TODO is it efficient enough?
|
||||
String name = p.getName();
|
||||
Iterator it = declaredProperties.iterator();
|
||||
while (it.hasNext()) {
|
||||
if ( name.equals( ((Property)it.next()).getName() ) ) {
|
||||
for (Property declaredProperty : declaredProperties) {
|
||||
if ( name.equals( declaredProperty.getName() ) ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
declaredProperties.add(p);
|
||||
}
|
||||
|
||||
public Class getMappedClass() {
|
||||
public Class<?> getMappedClass() {
|
||||
return mappedClass;
|
||||
}
|
||||
|
||||
public void setMappedClass(Class mappedClass) {
|
||||
public void setMappedClass(Class<?> mappedClass) {
|
||||
this.mappedClass = mappedClass;
|
||||
}
|
||||
|
||||
|
@ -173,9 +177,7 @@ public class MappedSuperclass {
|
|||
* @return {@code true} if a property with that name exists; {@code false} if not
|
||||
*/
|
||||
public boolean hasProperty(String name) {
|
||||
final Iterator itr = getDeclaredPropertyIterator();
|
||||
while ( itr.hasNext() ) {
|
||||
final Property property = (Property) itr.next();
|
||||
for ( Property property : getDeclaredProperties() ) {
|
||||
if ( property.getName().equals( name ) ) {
|
||||
return true;
|
||||
}
|
||||
|
@ -210,8 +212,7 @@ public class MappedSuperclass {
|
|||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
public void prepareForMappingModel() {
|
||||
( (List<Property>) declaredProperties ).sort( Comparator.comparing( Property::getName ) );
|
||||
declaredProperties.sort( Comparator.comparing( Property::getName ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,12 +67,7 @@ public final class MappingHelper {
|
|||
|
||||
public static void injectParameters(Object type, Properties parameters) {
|
||||
if ( type instanceof ParameterizedType ) {
|
||||
if ( parameters == null ) {
|
||||
( (ParameterizedType) type ).setParameterValues( EMPTY_PROPERTIES );
|
||||
}
|
||||
else {
|
||||
( (ParameterizedType) type ).setParameterValues( parameters );
|
||||
}
|
||||
( (ParameterizedType) type ).setParameterValues( parameters == null ? EMPTY_PROPERTIES : parameters );
|
||||
}
|
||||
else if ( parameters != null && !parameters.isEmpty() ) {
|
||||
MappingModelCreationLogger.LOGGER.debugf(
|
||||
|
|
|
@ -214,9 +214,25 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
|
|||
}
|
||||
|
||||
/**
|
||||
* Iterate over subclasses in a special 'order', most derived subclasses
|
||||
* first.
|
||||
* Get the subclasses in a special 'order', most derived subclasses first.
|
||||
*/
|
||||
public List<Subclass> getSubclasses() {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Subclass>[] iters = new List[subclasses.size() + 1];
|
||||
int i = 0;
|
||||
for ( Subclass subclass : subclasses ) {
|
||||
iters[i++] = subclass.getSubclasses();
|
||||
}
|
||||
iters[i] = subclasses;
|
||||
return new JoinedList<>( iters );
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate over subclasses in a special 'order', most derived subclasses first.
|
||||
*
|
||||
* @deprecated use {@link #getSubclasses()}
|
||||
*/
|
||||
@Deprecated(since = "6.0")
|
||||
public Iterator<Subclass> getSubclassIterator() {
|
||||
@SuppressWarnings("unchecked")
|
||||
Iterator<Subclass>[] iters = new Iterator[subclasses.size() + 1];
|
||||
|
@ -229,13 +245,21 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
|
|||
return new JoinedIterator<>( iters );
|
||||
}
|
||||
|
||||
public List<PersistentClass> getSubclassClosure() {
|
||||
ArrayList<List<PersistentClass>> lists = new ArrayList<>();
|
||||
lists.add( List.of( this ) );
|
||||
for ( Subclass subclass : getSubclasses() ) {
|
||||
lists.add( subclass.getSubclassClosure() );
|
||||
}
|
||||
return new JoinedList<>( lists );
|
||||
}
|
||||
|
||||
@Deprecated(since = "6.0")
|
||||
public Iterator<PersistentClass> getSubclassClosureIterator() {
|
||||
ArrayList<Iterator<PersistentClass>> iters = new ArrayList<>();
|
||||
iters.add( new SingletonIterator<>( this ) );
|
||||
Iterator<Subclass> iter = getSubclassIterator();
|
||||
while ( iter.hasNext() ) {
|
||||
PersistentClass clazz = iter.next();
|
||||
iters.add( clazz.getSubclassClosureIterator() );
|
||||
for ( Subclass subclass : getSubclasses() ) {
|
||||
iters.add( subclass.getSubclassClosureIterator() );
|
||||
}
|
||||
return new JoinedIterator<>( iters );
|
||||
}
|
||||
|
@ -244,8 +268,8 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
|
|||
return getRootTable();
|
||||
}
|
||||
|
||||
public Iterator<Subclass> getDirectSubclasses() {
|
||||
return subclasses.iterator();
|
||||
public List<Subclass> getDirectSubclasses() {
|
||||
return subclasses;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -328,6 +352,9 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
|
|||
@Deprecated(since = "6.0")
|
||||
public abstract Iterator<Table> getTableClosureIterator();
|
||||
|
||||
public abstract List<KeyValue> getKeyClosure();
|
||||
|
||||
@Deprecated(since = "6.0")
|
||||
public abstract Iterator<KeyValue> getKeyClosureIterator();
|
||||
|
||||
protected void addSubclassProperty(Property prop) {
|
||||
|
@ -783,7 +810,10 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
|
|||
* defined in superclasses of the mapping inheritance are not included.
|
||||
*
|
||||
* @return An iterator over the "normal" properties.
|
||||
*
|
||||
* @deprecated use {@link #getProperties()}
|
||||
*/
|
||||
@Deprecated(since = "6.0")
|
||||
public Iterator<Property> getPropertyIterator() {
|
||||
ArrayList<Iterator<Property>> iterators = new ArrayList<>();
|
||||
iterators.add( properties.iterator() );
|
||||
|
@ -1006,6 +1036,7 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
|
|||
return getUnjoinedProperties();
|
||||
}
|
||||
|
||||
@Deprecated(since = "6.0")
|
||||
protected Iterator<Selectable> getDiscriminatorColumnIterator() {
|
||||
return Collections.emptyIterator();
|
||||
}
|
||||
|
@ -1113,11 +1144,20 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
|
|||
}
|
||||
|
||||
// The following methods are added to support @MappedSuperclass in the metamodel
|
||||
public List<Property> getDeclaredProperties() {
|
||||
ArrayList<List<Property>> lists = new ArrayList<>();
|
||||
lists.add( declaredProperties );
|
||||
for (Join join : joins) {
|
||||
lists.add( join.getDeclaredProperties() );
|
||||
}
|
||||
return new JoinedList<>( lists );
|
||||
}
|
||||
|
||||
@Deprecated(since = "6.0")
|
||||
public Iterator<Property> getDeclaredPropertyIterator() {
|
||||
ArrayList<Iterator<Property>> iterators = new ArrayList<>();
|
||||
iterators.add( declaredProperties.iterator() );
|
||||
for ( int i = 0; i < joins.size(); i++ ) {
|
||||
Join join = joins.get( i );
|
||||
for (Join join : joins) {
|
||||
iterators.add( join.getDeclaredPropertyIterator() );
|
||||
}
|
||||
return new JoinedIterator<>( iterators );
|
||||
|
|
|
@ -28,9 +28,7 @@ public class PrimaryKey extends Constraint {
|
|||
|
||||
@Override
|
||||
public void addColumn(Column column) {
|
||||
final Iterator<Column> columnIterator = getTable().getColumnIterator();
|
||||
while ( columnIterator.hasNext() ) {
|
||||
final Column next = columnIterator.next();
|
||||
for ( Column next : getTable().getColumns() ) {
|
||||
if ( next.getCanonicalName().equals( column.getCanonicalName() ) ) {
|
||||
next.setNullable( false );
|
||||
if ( log.isDebugEnabled() ) {
|
||||
|
@ -62,9 +60,9 @@ public class PrimaryKey extends Constraint {
|
|||
|
||||
public String sqlConstraintString(Dialect dialect) {
|
||||
StringBuilder buf = new StringBuilder("primary key (");
|
||||
Iterator iter = getColumnIterator();
|
||||
Iterator<Column> iter = getColumnIterator();
|
||||
while ( iter.hasNext() ) {
|
||||
buf.append( ( (Column) iter.next() ).getQuotedName(dialect) );
|
||||
buf.append( iter.next().getQuotedName(dialect) );
|
||||
if ( iter.hasNext() ) {
|
||||
buf.append(", ");
|
||||
}
|
||||
|
|
|
@ -146,11 +146,16 @@ public class RootClass extends PersistentClass implements TableOwner {
|
|||
return List.of( getTable() );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @Deprecated
|
||||
public Iterator<KeyValue> getKeyClosureIterator() {
|
||||
return new SingletonIterator<>( getKey() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<KeyValue> getKeyClosure() {
|
||||
return List.of( getKey() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSubclass(Subclass subclass) throws MappingException {
|
||||
super.addSubclass( subclass );
|
||||
|
@ -351,9 +356,7 @@ public class RootClass extends PersistentClass implements TableOwner {
|
|||
|
||||
public Set<Table> getIdentityTables() {
|
||||
Set<Table> tables = new HashSet<>();
|
||||
Iterator<PersistentClass> iter = getSubclassClosureIterator();
|
||||
while ( iter.hasNext() ) {
|
||||
PersistentClass clazz = iter.next();
|
||||
for ( PersistentClass clazz : getSubclassClosure() ) {
|
||||
if ( clazz.isAbstract() == null || !clazz.isAbstract() ) {
|
||||
tables.add( clazz.getIdentityTable() );
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ public class SingleTableSubclass extends Subclass {
|
|||
return new JoinedList<>( getSuperclass().getUnjoinedProperties(), getUnjoinedProperties() );
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected Iterator<Selectable> getDiscriminatorColumnIterator() {
|
||||
return isDiscriminatorInsertable() && !getDiscriminator().hasFormula()
|
||||
? getDiscriminator().getColumnIterator()
|
||||
|
|
|
@ -155,7 +155,7 @@ public class Subclass extends PersistentClass {
|
|||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @Deprecated
|
||||
public Iterator<KeyValue> getKeyClosureIterator() {
|
||||
return new JoinedIterator<>(
|
||||
getSuperclass().getKeyClosureIterator(),
|
||||
|
@ -163,6 +163,14 @@ public class Subclass extends PersistentClass {
|
|||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<KeyValue> getKeyClosure() {
|
||||
return new JoinedList<>(
|
||||
getSuperclass().getKeyClosure(),
|
||||
List.of( getKey() )
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addSubclassProperty(Property p) {
|
||||
super.addSubclassProperty(p);
|
||||
|
|
|
@ -281,6 +281,7 @@ public class Table implements RelationalModel, Serializable, ContributableDataba
|
|||
return columns.size();
|
||||
}
|
||||
|
||||
@Deprecated(since = "6.0")
|
||||
public Iterator<Column> getColumnIterator() {
|
||||
return columns.values().iterator();
|
||||
}
|
||||
|
@ -293,6 +294,7 @@ public class Table implements RelationalModel, Serializable, ContributableDataba
|
|||
return indexes.values().iterator();
|
||||
}
|
||||
|
||||
@Deprecated(since = "6.0")
|
||||
public Iterator<ForeignKey> getForeignKeyIterator() {
|
||||
return foreignKeys.values().iterator();
|
||||
}
|
||||
|
@ -301,11 +303,12 @@ public class Table implements RelationalModel, Serializable, ContributableDataba
|
|||
return Collections.unmodifiableMap( foreignKeys );
|
||||
}
|
||||
|
||||
@Deprecated(since = "6.0")
|
||||
public Iterator<UniqueKey> getUniqueKeyIterator() {
|
||||
return getUniqueKeys().values().iterator();
|
||||
}
|
||||
|
||||
Map<String, UniqueKey> getUniqueKeys() {
|
||||
public Map<String, UniqueKey> getUniqueKeys() {
|
||||
cleanseUniqueKeyMapIfNeeded();
|
||||
return uniqueKeys;
|
||||
}
|
||||
|
@ -425,12 +428,12 @@ public class Table implements RelationalModel, Serializable, ContributableDataba
|
|||
.append( ' ' )
|
||||
.append( dialect.getAddColumnString() );
|
||||
|
||||
Iterator<Column> iter = getColumnIterator();
|
||||
List<String> results = new ArrayList<>();
|
||||
|
||||
while ( iter.hasNext() ) {
|
||||
final Column column = iter.next();
|
||||
final ColumnInformation columnInfo = tableInfo.getColumn( Identifier.toIdentifier( column.getName(), column.isQuoted() ) );
|
||||
for ( Column column : getColumns() ) {
|
||||
final ColumnInformation columnInfo = tableInfo.getColumn(
|
||||
Identifier.toIdentifier( column.getName(), column.isQuoted() )
|
||||
);
|
||||
|
||||
if ( columnInfo == null ) {
|
||||
// the column doesnt exist at all.
|
||||
|
@ -702,7 +705,7 @@ public class Table implements RelationalModel, Serializable, ContributableDataba
|
|||
fk.addColumn( keyColumn );
|
||||
}
|
||||
if ( referencedColumns != null ) {
|
||||
fk.addReferencedColumns( referencedColumns.iterator() );
|
||||
fk.addReferencedColumns( referencedColumns );
|
||||
}
|
||||
|
||||
// NOTE : if the name is null, we will generate an implicit name during second pass processing
|
||||
|
@ -811,10 +814,15 @@ public class Table implements RelationalModel, Serializable, ContributableDataba
|
|||
this.comment = comment;
|
||||
}
|
||||
|
||||
@Deprecated(since = "6.0")
|
||||
public Iterator<String> getCheckConstraintsIterator() {
|
||||
return checkConstraints.iterator();
|
||||
}
|
||||
|
||||
public List<String> getCheckConstraints() {
|
||||
return checkConstraints;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExportIdentifier() {
|
||||
return Table.qualify(
|
||||
|
|
|
@ -32,9 +32,7 @@ public class EntityInstantiatorDynamicMap
|
|||
|
||||
entityRoleNames.add( getRoleName() );
|
||||
if ( bootDescriptor.hasSubclasses() ) {
|
||||
final Iterator<PersistentClass> itr = bootDescriptor.getSubclassClosureIterator();
|
||||
while ( itr.hasNext() ) {
|
||||
final PersistentClass subclassInfo = itr.next();
|
||||
for ( PersistentClass subclassInfo : bootDescriptor.getSubclassClosure() ) {
|
||||
entityRoleNames.add( subclassInfo.getEntityName() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -208,9 +208,7 @@ public class EntityRepresentationStrategyPojoStandard implements EntityRepresent
|
|||
proxyInterfaces.add( mappedClass );
|
||||
}
|
||||
|
||||
final Iterator<Subclass> subclasses = bootDescriptor.getSubclassIterator();
|
||||
while ( subclasses.hasNext() ) {
|
||||
final Subclass subclass = subclasses.next();
|
||||
for ( Subclass subclass : bootDescriptor.getSubclasses() ) {
|
||||
final Class<?> subclassProxy = subclass.getProxyInterface();
|
||||
final Class<?> subclassClass = subclass.getMappedClass();
|
||||
if ( subclassProxy != null && !subclassClass.equals( subclassProxy ) ) {
|
||||
|
|
|
@ -11,7 +11,6 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -273,9 +272,7 @@ public class MetadataContext {
|
|||
applyIdMetadata( safeMapping, jpaMapping );
|
||||
applyVersionAttribute( safeMapping, jpaMapping );
|
||||
|
||||
Iterator<Property> properties = safeMapping.getDeclaredPropertyIterator();
|
||||
while ( properties.hasNext() ) {
|
||||
final Property property = properties.next();
|
||||
for ( Property property : safeMapping.getDeclaredProperties() ) {
|
||||
if ( property.getValue() == safeMapping.getIdentifierMapper() ) {
|
||||
// property represents special handling for id-class mappings but we have already
|
||||
// accounted for the embedded property mappings in #applyIdMetadata &&
|
||||
|
@ -324,9 +321,7 @@ public class MetadataContext {
|
|||
applyVersionAttribute( safeMapping, jpaType );
|
||||
// applyNaturalIdAttribute( safeMapping, jpaType );
|
||||
|
||||
Iterator<Property> properties = safeMapping.getDeclaredPropertyIterator();
|
||||
while ( properties.hasNext() ) {
|
||||
final Property property = properties.next();
|
||||
for ( Property property : safeMapping.getDeclaredProperties() ) {
|
||||
if ( safeMapping.isVersioned() && property == safeMapping.getVersion() ) {
|
||||
// skip the version property, it was already handled previously.
|
||||
continue;
|
||||
|
|
|
@ -1155,9 +1155,7 @@ public abstract class AbstractEntityPersister
|
|||
return true;
|
||||
}
|
||||
|
||||
final Iterator<Subclass> subclassIterator = persistentClass.getSubclassIterator();
|
||||
while ( subclassIterator.hasNext() ) {
|
||||
final Subclass subclass = subclassIterator.next();
|
||||
for ( Subclass subclass : persistentClass.getSubclasses() ) {
|
||||
if ( subclass.isCached() ) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -249,11 +249,11 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
ArrayList<String[]> keyColumnReaders = new ArrayList<>();
|
||||
ArrayList<String[]> keyColumnReaderTemplates = new ArrayList<>();
|
||||
ArrayList<Boolean> cascadeDeletes = new ArrayList<>();
|
||||
Iterator<Table> tItr = persistentClass.getTableClosureIterator();
|
||||
Iterator<KeyValue> kItr = persistentClass.getKeyClosureIterator();
|
||||
while ( tItr.hasNext() ) {
|
||||
final Table table = tItr.next();
|
||||
final KeyValue key = kItr.next();
|
||||
List<Table> tItr = persistentClass.getTableClosure();
|
||||
List<KeyValue> kItr = persistentClass.getKeyClosure();
|
||||
for ( int i = 0; i < tItr.size() && i < kItr.size(); i++ ) {
|
||||
final Table table = tItr.get(i);
|
||||
final KeyValue key = kItr.get(i);
|
||||
final String tableName = determineTableName( table );
|
||||
tableNames.add( tableName );
|
||||
String[] keyCols = new String[idColumnSpan];
|
||||
|
@ -562,26 +562,25 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
notNullColumnNames = null;
|
||||
}
|
||||
|
||||
Iterator<Subclass> siter = persistentClass.getSubclassIterator();
|
||||
int k = 0;
|
||||
while ( siter.hasNext() ) {
|
||||
Subclass sc = siter.next();
|
||||
subclassClosure[k] = sc.getEntityName();
|
||||
final Table table = sc.getTable();
|
||||
subclassNameByTableName.put( table.getName(), sc.getEntityName() );
|
||||
for ( Subclass subclass : persistentClass.getSubclasses() ) {
|
||||
subclassClosure[k] = subclass.getEntityName();
|
||||
final Table table = subclass.getTable();
|
||||
subclassNameByTableName.put( table.getName(), subclass.getEntityName() );
|
||||
try {
|
||||
if ( persistentClass.isPolymorphic() ) {
|
||||
final Object discriminatorValue;
|
||||
if ( explicitDiscriminatorColumnName != null ) {
|
||||
if ( sc.isDiscriminatorValueNull() ) {
|
||||
if ( subclass.isDiscriminatorValueNull() ) {
|
||||
discriminatorValue = NULL_DISCRIMINATOR;
|
||||
}
|
||||
else if ( sc.isDiscriminatorValueNotNull() ) {
|
||||
else if ( subclass.isDiscriminatorValueNotNull() ) {
|
||||
discriminatorValue = NOT_NULL_DISCRIMINATOR;
|
||||
}
|
||||
else {
|
||||
try {
|
||||
discriminatorValue = discriminatorType.getJavaTypeDescriptor().fromString( sc.getDiscriminatorValue() );
|
||||
discriminatorValue = discriminatorType.getJavaTypeDescriptor()
|
||||
.fromString( subclass.getDiscriminatorValue() );
|
||||
}
|
||||
catch (ClassCastException cce) {
|
||||
throw new MappingException( "Illegal discriminator type: " + discriminatorType.getName() );
|
||||
|
@ -595,10 +594,10 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
// we now use subclass ids that are consistent across all
|
||||
// persisters for a class hierarchy, so that the use of
|
||||
// "foo.class = Bar" works in HQL
|
||||
discriminatorValue = sc.getSubclassId();
|
||||
discriminatorValue = subclass.getSubclassId();
|
||||
}
|
||||
initDiscriminatorProperties( factory, k, table, discriminatorValue );
|
||||
subclassesByDiscriminatorValue.put( discriminatorValue, sc.getEntityName() );
|
||||
subclassesByDiscriminatorValue.put( discriminatorValue, subclass.getEntityName() );
|
||||
int id = getTableId(
|
||||
table.getQualifiedName(
|
||||
factory.getSqlStringGenerationContext()
|
||||
|
@ -700,9 +699,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
// included when one of the collected class names is used in TREAT
|
||||
final Set<String> classNames = new HashSet<>();
|
||||
|
||||
final Iterator<Subclass> itr = persistentClass.getDirectSubclasses();
|
||||
while ( itr.hasNext() ) {
|
||||
final Subclass subclass = itr.next();
|
||||
for ( Subclass subclass : persistentClass.getDirectSubclasses() ) {
|
||||
final Set<String> subclassSubclassNames = processPersistentClassHierarchy(
|
||||
subclass,
|
||||
false,
|
||||
|
|
|
@ -9,7 +9,6 @@ package org.hibernate.persister.entity;
|
|||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -412,23 +411,21 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
|||
|
||||
// SUBCLASSES
|
||||
if ( persistentClass.isPolymorphic() ) {
|
||||
Iterator<Subclass> subclasses = persistentClass.getSubclassIterator();
|
||||
int k = 1;
|
||||
while ( subclasses.hasNext() ) {
|
||||
Subclass sc = subclasses.next();
|
||||
subclassClosure[k++] = sc.getEntityName();
|
||||
if ( sc.isDiscriminatorValueNull() ) {
|
||||
addSubclassByDiscriminatorValue( subclassesByDiscriminatorValueLocal, NULL_DISCRIMINATOR, sc.getEntityName() );
|
||||
for ( Subclass subclass : persistentClass.getSubclasses() ) {
|
||||
subclassClosure[k++] = subclass.getEntityName();
|
||||
if ( subclass.isDiscriminatorValueNull() ) {
|
||||
addSubclassByDiscriminatorValue( subclassesByDiscriminatorValueLocal, NULL_DISCRIMINATOR, subclass.getEntityName() );
|
||||
}
|
||||
else if ( sc.isDiscriminatorValueNotNull() ) {
|
||||
addSubclassByDiscriminatorValue( subclassesByDiscriminatorValueLocal, NOT_NULL_DISCRIMINATOR, sc.getEntityName() );
|
||||
else if ( subclass.isDiscriminatorValueNotNull() ) {
|
||||
addSubclassByDiscriminatorValue( subclassesByDiscriminatorValueLocal, NOT_NULL_DISCRIMINATOR, subclass.getEntityName() );
|
||||
}
|
||||
else {
|
||||
try {
|
||||
addSubclassByDiscriminatorValue(
|
||||
subclassesByDiscriminatorValueLocal,
|
||||
discriminatorType.getJavaTypeDescriptor().fromString( sc.getDiscriminatorValue() ),
|
||||
sc.getEntityName()
|
||||
discriminatorType.getJavaTypeDescriptor().fromString( subclass.getDiscriminatorValue() ),
|
||||
subclass.getEntityName()
|
||||
);
|
||||
}
|
||||
catch (ClassCastException cce) {
|
||||
|
|
|
@ -34,8 +34,7 @@ import org.hibernate.id.IdentityGenerator;
|
|||
import org.hibernate.internal.FilterAliasGenerator;
|
||||
import org.hibernate.internal.StaticFilterAliasGenerator;
|
||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||
import org.hibernate.internal.util.collections.JoinedIterator;
|
||||
import org.hibernate.internal.util.collections.SingletonIterator;
|
||||
import org.hibernate.internal.util.collections.JoinedList;
|
||||
import org.hibernate.mapping.Column;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.Subclass;
|
||||
|
@ -162,9 +161,7 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
|
|||
persistentClass.getEntityName()
|
||||
);
|
||||
if ( persistentClass.isPolymorphic() ) {
|
||||
Iterator<Subclass> subclassIter = persistentClass.getSubclassIterator();
|
||||
while ( subclassIter.hasNext() ) {
|
||||
Subclass subclass = subclassIter.next();
|
||||
for ( Subclass subclass : persistentClass.getSubclasses() ) {
|
||||
subclassByDiscriminatorValue.put( subclass.getSubclassId(), subclass.getEntityName() );
|
||||
}
|
||||
}
|
||||
|
@ -196,9 +193,7 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
|
|||
tableExpressions.add( generateSubquery( parentPersistentClass, creationContext.getMetadata() ) );
|
||||
parentPersistentClass = parentPersistentClass.getSuperclass();
|
||||
}
|
||||
final Iterator<PersistentClass> subclassClosureIterator = persistentClass.getSubclassClosureIterator();
|
||||
while ( subclassClosureIterator.hasNext() ) {
|
||||
final PersistentClass subPersistentClass = subclassClosureIterator.next();
|
||||
for ( PersistentClass subPersistentClass : persistentClass.getSubclassClosure() ) {
|
||||
if ( subPersistentClass.hasSubclasses() ) {
|
||||
tableExpressions.add( generateSubquery( subPersistentClass, creationContext.getMetadata() ) );
|
||||
}
|
||||
|
@ -475,13 +470,12 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
|
|||
StringBuilder buf = new StringBuilder()
|
||||
.append( "( " );
|
||||
|
||||
Iterator<PersistentClass> siter = new JoinedIterator<>(
|
||||
new SingletonIterator<>( model ),
|
||||
model.getSubclassIterator()
|
||||
List<PersistentClass> classes = new JoinedList<>(
|
||||
List.of( model ),
|
||||
Collections.unmodifiableList( model.getSubclasses() )
|
||||
);
|
||||
|
||||
while ( siter.hasNext() ) {
|
||||
PersistentClass clazz = siter.next();
|
||||
for ( PersistentClass clazz : classes ) {
|
||||
Table table = clazz.getTable();
|
||||
if ( !table.isAbstractUnionTable() ) {
|
||||
//TODO: move to .sql package!!
|
||||
|
|
|
@ -28,29 +28,30 @@ import org.hibernate.persister.spi.UnknownPersisterException;
|
|||
public class StandardPersisterClassResolver implements PersisterClassResolver {
|
||||
|
||||
@Override
|
||||
public Class<? extends EntityPersister> getEntityPersisterClass(PersistentClass metadata) {
|
||||
// todo : make sure this is based on an attribute kept on the metamodel in the new code, not the concrete PersistentClass impl found!
|
||||
if ( RootClass.class.isInstance( metadata ) ) {
|
||||
if ( metadata.hasSubclasses() ) {
|
||||
public Class<? extends EntityPersister> getEntityPersisterClass(PersistentClass model) {
|
||||
// todo : make sure this is based on an attribute kept on the metamodel in the new code,
|
||||
// not the concrete PersistentClass impl found!
|
||||
if ( model instanceof RootClass ) {
|
||||
if ( model.hasSubclasses() ) {
|
||||
//If the class has children, we need to find of which kind
|
||||
metadata = (PersistentClass) metadata.getDirectSubclasses().next();
|
||||
model = model.getDirectSubclasses().get(0);
|
||||
}
|
||||
else {
|
||||
return singleTableEntityPersister();
|
||||
}
|
||||
}
|
||||
if ( JoinedSubclass.class.isInstance( metadata ) ) {
|
||||
if ( model instanceof JoinedSubclass ) {
|
||||
return joinedSubclassEntityPersister();
|
||||
}
|
||||
else if ( UnionSubclass.class.isInstance( metadata ) ) {
|
||||
else if ( model instanceof UnionSubclass ) {
|
||||
return unionSubclassEntityPersister();
|
||||
}
|
||||
else if ( SingleTableSubclass.class.isInstance( metadata ) ) {
|
||||
else if ( model instanceof SingleTableSubclass ) {
|
||||
return singleTableEntityPersister();
|
||||
}
|
||||
else {
|
||||
throw new UnknownPersisterException(
|
||||
"Could not determine persister implementation for entity [" + metadata.getEntityName() + "]"
|
||||
"Could not determine persister implementation for entity [" + model.getEntityName() + "]"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.hibernate.proxy.pojo;
|
|||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
|
@ -50,9 +49,7 @@ public final class ProxyFactoryHelper {
|
|||
proxyInterfaces.add( mappedClass );
|
||||
}
|
||||
|
||||
Iterator<Subclass> subclasses = persistentClass.getSubclassIterator();
|
||||
while ( subclasses.hasNext() ) {
|
||||
final Subclass subclass = subclasses.next();
|
||||
for ( Subclass subclass : persistentClass.getSubclasses() ) {
|
||||
final Class<?> subclassProxy = subclass.getProxyInterface();
|
||||
final Class<?> subclassClass = subclass.getMappedClass();
|
||||
if ( subclassProxy != null && !subclassClass.equals( subclassProxy ) ) {
|
||||
|
|
|
@ -75,12 +75,9 @@ public abstract class AbstractSchemaMigrator implements SchemaMigrator {
|
|||
HibernateSchemaManagementTool tool,
|
||||
SchemaFilter schemaFilter) {
|
||||
this.tool = tool;
|
||||
if ( schemaFilter == null ) {
|
||||
this.schemaFilter = DefaultSchemaFilter.INSTANCE;
|
||||
}
|
||||
else {
|
||||
this.schemaFilter = schemaFilter;
|
||||
}
|
||||
this.schemaFilter = schemaFilter == null
|
||||
? DefaultSchemaFilter.INSTANCE
|
||||
: schemaFilter;
|
||||
}
|
||||
|
||||
private UniqueConstraintSchemaUpdateStrategy uniqueConstraintStrategy;
|
||||
|
@ -325,9 +322,6 @@ public abstract class AbstractSchemaMigrator implements SchemaMigrator {
|
|||
ExecutionOptions options,
|
||||
SqlStringGenerationContext sqlStringGenerationContext,
|
||||
GenerationTarget... targets) {
|
||||
final Database database = metadata.getDatabase();
|
||||
|
||||
//noinspection unchecked
|
||||
applySqlStrings(
|
||||
false,
|
||||
table.sqlAlterStrings(
|
||||
|
@ -394,9 +388,7 @@ public abstract class AbstractSchemaMigrator implements SchemaMigrator {
|
|||
if ( uniqueConstraintStrategy != UniqueConstraintSchemaUpdateStrategy.SKIP ) {
|
||||
final Exporter<Constraint> exporter = dialect.getUniqueKeyExporter();
|
||||
|
||||
final Iterator ukItr = table.getUniqueKeyIterator();
|
||||
while ( ukItr.hasNext() ) {
|
||||
final UniqueKey uniqueKey = (UniqueKey) ukItr.next();
|
||||
for ( UniqueKey uniqueKey : table.getUniqueKeys().values() ) {
|
||||
// Skip if index already exists. Most of the time, this
|
||||
// won't work since most Dialects use Constraints. However,
|
||||
// keep it for the few that do use Indexes.
|
||||
|
@ -449,10 +441,7 @@ public abstract class AbstractSchemaMigrator implements SchemaMigrator {
|
|||
if ( dialect.hasAlterTable() ) {
|
||||
final Exporter<ForeignKey> exporter = dialect.getForeignKeyExporter();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
final Iterator<ForeignKey> fkItr = table.getForeignKeyIterator();
|
||||
while ( fkItr.hasNext() ) {
|
||||
final ForeignKey foreignKey = fkItr.next();
|
||||
for ( ForeignKey foreignKey : table.getForeignKeys().values() ) {
|
||||
if ( foreignKey.isPhysicalConstraint() && foreignKey.isCreationEnabled() ) {
|
||||
boolean existingForeignKeyFound = false;
|
||||
if ( tableInformation != null ) {
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
*/
|
||||
package org.hibernate.tool.schema.internal;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.hibernate.boot.Metadata;
|
||||
|
@ -137,9 +136,7 @@ public abstract class AbstractSchemaValidator implements SchemaValidator {
|
|||
);
|
||||
}
|
||||
|
||||
final Iterator<Column> columnIter = table.getColumnIterator();
|
||||
while ( columnIter.hasNext() ) {
|
||||
final Column column = columnIter.next();
|
||||
for ( Column column : table.getColumns() ) {
|
||||
final ColumnInformation existingColumn = tableInformation.getColumn( Identifier.toIdentifier( column.getQuotedName() ) );
|
||||
if ( existingColumn == null ) {
|
||||
throw new SchemaManagementException(
|
||||
|
|
|
@ -397,9 +397,7 @@ public class SchemaCreatorImpl implements SchemaCreator {
|
|||
}
|
||||
|
||||
// unique keys
|
||||
final Iterator<UniqueKey> ukItr = table.getUniqueKeyIterator();
|
||||
while ( ukItr.hasNext() ) {
|
||||
final UniqueKey uniqueKey = ukItr.next();
|
||||
for ( UniqueKey uniqueKey : table.getUniqueKeys().values() ) {
|
||||
checkExportIdentifier( uniqueKey, exportIdentifiers );
|
||||
applySqlStrings(
|
||||
dialect.getUniqueKeyExporter().getSqlCreateStrings( uniqueKey, metadata,
|
||||
|
@ -431,9 +429,7 @@ public class SchemaCreatorImpl implements SchemaCreator {
|
|||
}
|
||||
|
||||
// foreign keys
|
||||
final Iterator<ForeignKey> fkItr = table.getForeignKeyIterator();
|
||||
while ( fkItr.hasNext() ) {
|
||||
final ForeignKey foreignKey = fkItr.next();
|
||||
for ( ForeignKey foreignKey : table.getForeignKeys().values() ) {
|
||||
applySqlStrings(
|
||||
dialect.getForeignKeyExporter().getSqlCreateStrings( foreignKey, metadata,
|
||||
sqlStringGenerationContext
|
||||
|
|
|
@ -10,7 +10,6 @@ import java.io.Serializable;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -370,9 +369,7 @@ public class SchemaDropperImpl implements SchemaDropper {
|
|||
continue;
|
||||
}
|
||||
|
||||
final Iterator<ForeignKey> fks = table.getForeignKeyIterator();
|
||||
while ( fks.hasNext() ) {
|
||||
final ForeignKey foreignKey = fks.next();
|
||||
for ( ForeignKey foreignKey : table.getForeignKeys().values() ) {
|
||||
applySqlStrings(
|
||||
dialect.getForeignKeyExporter().getSqlDropStrings( foreignKey, metadata,
|
||||
sqlStringGenerationContext
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.hibernate.boot.model.relational.QualifiedNameParser;
|
|||
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.mapping.Column;
|
||||
import org.hibernate.mapping.Constraint;
|
||||
import org.hibernate.mapping.Table;
|
||||
|
@ -70,10 +71,8 @@ public class StandardTableExporter implements Exporter<Table> {
|
|||
pkColName = pkColumn.getQuotedName( dialect );
|
||||
}
|
||||
|
||||
final Iterator columnItr = table.getColumnIterator();
|
||||
boolean isFirst = true;
|
||||
while ( columnItr.hasNext() ) {
|
||||
final Column col = (Column) columnItr.next();
|
||||
for ( Column col : table.getColumns() ) {
|
||||
if ( isFirst ) {
|
||||
isFirst = false;
|
||||
}
|
||||
|
@ -162,7 +161,7 @@ public class StandardTableExporter implements Exporter<Table> {
|
|||
|
||||
applyInitCommands( table, sqlStrings, context );
|
||||
|
||||
return sqlStrings.toArray( new String[ sqlStrings.size() ] );
|
||||
return sqlStrings.toArray(StringHelper.EMPTY_STRINGS);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new MappingException( "Error creating SQL create commands for table : " + tableName, e );
|
||||
|
@ -174,9 +173,7 @@ public class StandardTableExporter implements Exporter<Table> {
|
|||
if ( table.getComment() != null ) {
|
||||
sqlStrings.add( "comment on table " + tableName + " is '" + table.getComment() + "'" );
|
||||
}
|
||||
final Iterator iter = table.getColumnIterator();
|
||||
while ( iter.hasNext() ) {
|
||||
Column column = (Column) iter.next();
|
||||
for ( Column column : table.getColumns() ) {
|
||||
String columnComment = column.getComment();
|
||||
if ( columnComment != null ) {
|
||||
sqlStrings.add( "comment on column " + tableName + '.' + column.getQuotedName( dialect ) + " is '" + columnComment + "'" );
|
||||
|
@ -197,10 +194,9 @@ public class StandardTableExporter implements Exporter<Table> {
|
|||
|
||||
protected void applyTableCheck(Table table, StringBuilder buf) {
|
||||
if ( dialect.supportsTableCheck() ) {
|
||||
final Iterator<String> checkConstraints = table.getCheckConstraintsIterator();
|
||||
while ( checkConstraints.hasNext() ) {
|
||||
for (String constraint : table.getCheckConstraints() ) {
|
||||
buf.append( ", check (" )
|
||||
.append( checkConstraints.next() )
|
||||
.append( constraint )
|
||||
.append( ')' );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.hibernate.tuple;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -28,9 +27,7 @@ public class DynamicMapInstantiator implements Instantiator {
|
|||
this.roleName = mappingInfo.getEntityName();
|
||||
isInstanceEntityNames.add( roleName );
|
||||
if ( mappingInfo.hasSubclasses() ) {
|
||||
Iterator<PersistentClass> itr = mappingInfo.getSubclassClosureIterator();
|
||||
while ( itr.hasNext() ) {
|
||||
final PersistentClass subclassInfo = itr.next();
|
||||
for ( PersistentClass subclassInfo : mappingInfo.getSubclassClosure() ) {
|
||||
isInstanceEntityNames.add( subclassInfo.getEntityName() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.hibernate.internal.util.collections.CollectionHelper;
|
|||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.Property;
|
||||
import org.hibernate.mapping.Subclass;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
||||
import org.hibernate.tuple.GenerationTiming;
|
||||
|
@ -404,10 +405,9 @@ public class EntityMetamodel implements Serializable {
|
|||
hasCollections = foundCollection;
|
||||
mutablePropertiesIndexes = mutableIndexes;
|
||||
|
||||
Iterator<?> iter = persistentClass.getSubclassIterator();
|
||||
final Set<String> subclassEntityNamesLocal = new HashSet<>();
|
||||
while ( iter.hasNext() ) {
|
||||
subclassEntityNamesLocal.add( ( (PersistentClass) iter.next() ).getEntityName() );
|
||||
for ( Subclass subclass : persistentClass.getSubclasses() ) {
|
||||
subclassEntityNamesLocal.add( subclass.getEntityName() );
|
||||
}
|
||||
subclassEntityNamesLocal.add( name );
|
||||
subclassEntityNames = CollectionHelper.toSmallSet( subclassEntityNamesLocal );
|
||||
|
@ -415,10 +415,8 @@ public class EntityMetamodel implements Serializable {
|
|||
HashMap<Class<?>, String> entityNameByInheritanceClassMapLocal = new HashMap<>();
|
||||
if ( persistentClass.hasPojoRepresentation() ) {
|
||||
entityNameByInheritanceClassMapLocal.put( persistentClass.getMappedClass(), persistentClass.getEntityName() );
|
||||
iter = persistentClass.getSubclassIterator();
|
||||
while ( iter.hasNext() ) {
|
||||
final PersistentClass pc = ( PersistentClass ) iter.next();
|
||||
entityNameByInheritanceClassMapLocal.put( pc.getMappedClass(), pc.getEntityName() );
|
||||
for ( Subclass subclass : persistentClass.getSubclasses() ) {
|
||||
entityNameByInheritanceClassMapLocal.put( subclass.getMappedClass(), subclass.getEntityName() );
|
||||
}
|
||||
}
|
||||
entityNameByInheritenceClassMap = CollectionHelper.toSmallMap( entityNameByInheritanceClassMapLocal );
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.hibernate.mapping.PersistentClass;
|
|||
import org.hibernate.mapping.Property;
|
||||
import org.hibernate.mapping.Selectable;
|
||||
import org.hibernate.mapping.Table;
|
||||
import org.hibernate.mapping.Value;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
|
@ -149,12 +148,10 @@ public class CollectionMappedByResolver {
|
|||
}
|
||||
|
||||
private static String searchMappedByKey(PersistentClass referencedClass, Collection collectionValue) {
|
||||
final Iterator<KeyValue> assocIdClassProps = referencedClass.getKeyClosureIterator();
|
||||
while ( assocIdClassProps.hasNext() ) {
|
||||
final Value value = assocIdClassProps.next();
|
||||
for ( KeyValue keyValue : referencedClass.getKeyClosure() ) {
|
||||
// make sure it's a 'Component' because IdClass is registered as this type.
|
||||
if ( value instanceof Component ) {
|
||||
final Component component = (Component) value;
|
||||
if ( keyValue instanceof Component ) {
|
||||
final Component component = (Component) keyValue;
|
||||
final Iterator<Property> componentPropertyIterator = component.getPropertyIterator();
|
||||
while ( componentPropertyIterator.hasNext() ) {
|
||||
final Property property = componentPropertyIterator.next();
|
||||
|
|
Loading…
Reference in New Issue