HHH-18506 Improve flush performance by reducing itable stubs
This commit is contained in:
parent
f261d87463
commit
4bb02cd929
|
@ -15,8 +15,11 @@ import org.hibernate.AssertionFailure;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
|
import org.hibernate.type.AnyType;
|
||||||
import org.hibernate.type.CollectionType;
|
import org.hibernate.type.CollectionType;
|
||||||
|
import org.hibernate.type.ComponentType;
|
||||||
import org.hibernate.type.CompositeType;
|
import org.hibernate.type.CompositeType;
|
||||||
|
import org.hibernate.type.EntityType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
|
||||||
import jakarta.validation.Path;
|
import jakarta.validation.Path;
|
||||||
|
@ -54,17 +57,17 @@ public class HibernateTraversableResolver implements TraversableResolver {
|
||||||
|
|
||||||
private void addAssociationsToTheSetForOneProperty(String name, Type type, String prefix, SessionFactoryImplementor factory) {
|
private void addAssociationsToTheSetForOneProperty(String name, Type type, String prefix, SessionFactoryImplementor factory) {
|
||||||
|
|
||||||
if ( type.isCollectionType() ) {
|
if ( type instanceof CollectionType ) {
|
||||||
CollectionType collType = (CollectionType) type;
|
CollectionType collType = (CollectionType) type;
|
||||||
Type assocType = collType.getElementType( factory );
|
Type assocType = collType.getElementType( factory );
|
||||||
addAssociationsToTheSetForOneProperty(name, assocType, prefix, factory);
|
addAssociationsToTheSetForOneProperty(name, assocType, prefix, factory);
|
||||||
}
|
}
|
||||||
//ToOne association
|
//ToOne association
|
||||||
else if ( type.isEntityType() || type.isAnyType() ) {
|
else if ( type instanceof EntityType || type instanceof AnyType ) {
|
||||||
associations.add( prefix + name );
|
associations.add( prefix + name );
|
||||||
}
|
}
|
||||||
else if ( type.isComponentType() ) {
|
else if ( type instanceof ComponentType ) {
|
||||||
CompositeType componentType = (CompositeType) type;
|
ComponentType componentType = (ComponentType) type;
|
||||||
addAssociationsToTheSetForAllProperties(
|
addAssociationsToTheSetForAllProperties(
|
||||||
componentType.getPropertyNames(),
|
componentType.getPropertyNames(),
|
||||||
componentType.getSubtypes(),
|
componentType.getSubtypes(),
|
||||||
|
|
|
@ -19,6 +19,7 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||||
import org.hibernate.metamodel.mapping.AttributeMapping;
|
import org.hibernate.metamodel.mapping.AttributeMapping;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
|
import org.hibernate.type.CollectionType;
|
||||||
import org.hibernate.type.CompositeType;
|
import org.hibernate.type.CompositeType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
|
||||||
|
@ -67,7 +68,7 @@ public class EnhancementAsProxyLazinessInterceptor extends AbstractLazyLoadInter
|
||||||
collectionAttributeNames = new HashSet<>();
|
collectionAttributeNames = new HashSet<>();
|
||||||
for ( int i = 0; i < propertyTypes.length; i++ ) {
|
for ( int i = 0; i < propertyTypes.length; i++ ) {
|
||||||
Type propertyType = propertyTypes[i];
|
Type propertyType = propertyTypes[i];
|
||||||
if ( propertyType.isCollectionType() ) {
|
if ( propertyType instanceof CollectionType ) {
|
||||||
collectionAttributeNames.add( entityPersister.getPropertyNames()[i] );
|
collectionAttributeNames.add( entityPersister.getPropertyNames()[i] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
package org.hibernate.bytecode.enhance.spi.interceptor;
|
package org.hibernate.bytecode.enhance.spi.interceptor;
|
||||||
|
|
||||||
import org.hibernate.mapping.Property;
|
import org.hibernate.mapping.Property;
|
||||||
|
import org.hibernate.type.CollectionType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,7 +22,7 @@ public class LazyAttributeDescriptor {
|
||||||
int lazyIndex) {
|
int lazyIndex) {
|
||||||
String fetchGroupName = property.getLazyGroup();
|
String fetchGroupName = property.getLazyGroup();
|
||||||
if ( fetchGroupName == null ) {
|
if ( fetchGroupName == null ) {
|
||||||
fetchGroupName = property.getType().isCollectionType()
|
fetchGroupName = property.getType() instanceof CollectionType
|
||||||
? property.getName()
|
? property.getName()
|
||||||
: "DEFAULT";
|
: "DEFAULT";
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,12 +28,14 @@ import org.hibernate.persister.collection.CollectionPersister;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.pretty.MessageHelper;
|
import org.hibernate.pretty.MessageHelper;
|
||||||
import org.hibernate.proxy.HibernateProxy;
|
import org.hibernate.proxy.HibernateProxy;
|
||||||
|
import org.hibernate.type.AnyType;
|
||||||
import org.hibernate.type.AssociationType;
|
import org.hibernate.type.AssociationType;
|
||||||
import org.hibernate.type.CollectionType;
|
import org.hibernate.type.CollectionType;
|
||||||
import org.hibernate.type.ComponentType;
|
import org.hibernate.type.ComponentType;
|
||||||
import org.hibernate.type.CompositeType;
|
import org.hibernate.type.CompositeType;
|
||||||
import org.hibernate.type.EntityType;
|
import org.hibernate.type.EntityType;
|
||||||
import org.hibernate.type.ForeignKeyDirection;
|
import org.hibernate.type.ForeignKeyDirection;
|
||||||
|
import org.hibernate.type.OneToOneType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
|
||||||
import static org.hibernate.engine.internal.ManagedTypeHelper.isHibernateProxy;
|
import static org.hibernate.engine.internal.ManagedTypeHelper.isHibernateProxy;
|
||||||
|
@ -125,7 +127,7 @@ public final class Cascade {
|
||||||
// parent was not in the PersistenceContext
|
// parent was not in the PersistenceContext
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( type.isCollectionType() ) {
|
if ( type instanceof CollectionType ) {
|
||||||
// CollectionType#getCollection gets the PersistentCollection
|
// CollectionType#getCollection gets the PersistentCollection
|
||||||
// that corresponds to the uninitialized collection from the
|
// that corresponds to the uninitialized collection from the
|
||||||
// PersistenceContext. If not present, an uninitialized
|
// PersistenceContext. If not present, an uninitialized
|
||||||
|
@ -140,13 +142,13 @@ public final class Cascade {
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if ( type.isComponentType() ) {
|
else if ( type instanceof AnyType || type instanceof ComponentType ) {
|
||||||
// Hibernate does not support lazy embeddables, so this shouldn't happen.
|
// Hibernate does not support lazy embeddables, so this shouldn't happen.
|
||||||
throw new UnsupportedOperationException(
|
throw new UnsupportedOperationException(
|
||||||
"Lazy components are not supported."
|
"Lazy components are not supported."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if ( action.performOnLazyProperty() && type.isEntityType() ) {
|
else if ( action.performOnLazyProperty() && type instanceof EntityType ) {
|
||||||
// Only need to initialize a lazy entity attribute when action.performOnLazyProperty()
|
// Only need to initialize a lazy entity attribute when action.performOnLazyProperty()
|
||||||
// returns true.
|
// returns true.
|
||||||
LazyAttributeLoadingInterceptor interceptor = persister.getBytecodeEnhancementMetadata()
|
LazyAttributeLoadingInterceptor interceptor = persister.getBytecodeEnhancementMetadata()
|
||||||
|
@ -226,7 +228,7 @@ public final class Cascade {
|
||||||
final boolean isCascadeDeleteEnabled) throws HibernateException {
|
final boolean isCascadeDeleteEnabled) throws HibernateException {
|
||||||
|
|
||||||
if ( child != null ) {
|
if ( child != null ) {
|
||||||
if ( type.isAssociationType() ) {
|
if ( type instanceof EntityType || type instanceof CollectionType || type instanceof AnyType ) {
|
||||||
final AssociationType associationType = (AssociationType) type;
|
final AssociationType associationType = (AssociationType) type;
|
||||||
if ( cascadeAssociationNow( cascadePoint, associationType ) ) {
|
if ( cascadeAssociationNow( cascadePoint, associationType ) ) {
|
||||||
cascadeAssociation(
|
cascadeAssociation(
|
||||||
|
@ -243,7 +245,7 @@ public final class Cascade {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( type.isComponentType() ) {
|
else if ( type instanceof ComponentType ) {
|
||||||
if ( componentPath == null && propertyName != null ) {
|
if ( componentPath == null && propertyName != null ) {
|
||||||
componentPath = new ArrayList<>();
|
componentPath = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
@ -358,9 +360,8 @@ public final class Cascade {
|
||||||
LOG.tracev( "Deleting orphaned entity instance: {0}", description );
|
LOG.tracev( "Deleting orphaned entity instance: {0}", description );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( type.isAssociationType() && ( (AssociationType) type ).getForeignKeyDirection().equals(
|
if ( type instanceof CollectionType
|
||||||
ForeignKeyDirection.TO_PARENT
|
|| type instanceof OneToOneType && ( (OneToOneType) type ).getForeignKeyDirection() == ForeignKeyDirection.TO_PARENT ) {
|
||||||
) ) {
|
|
||||||
// If FK direction is to-parent, we must remove the orphan *before* the queued update(s)
|
// If FK direction is to-parent, we must remove the orphan *before* the queued update(s)
|
||||||
// occur. Otherwise, replacing the association on a managed entity, without manually
|
// occur. Otherwise, replacing the association on a managed entity, without manually
|
||||||
// nulling and flushing, causes FK constraint violations.
|
// nulling and flushing, causes FK constraint violations.
|
||||||
|
@ -442,10 +443,10 @@ public final class Cascade {
|
||||||
final CascadeStyle style,
|
final CascadeStyle style,
|
||||||
final T anything,
|
final T anything,
|
||||||
final boolean isCascadeDeleteEnabled) {
|
final boolean isCascadeDeleteEnabled) {
|
||||||
if ( type.isEntityType() || type.isAnyType() ) {
|
if ( type instanceof EntityType || type instanceof AnyType ) {
|
||||||
cascadeToOne( action, eventSource, parent, child, type, style, anything, isCascadeDeleteEnabled );
|
cascadeToOne( action, eventSource, parent, child, type, style, anything, isCascadeDeleteEnabled );
|
||||||
}
|
}
|
||||||
else if ( type.isCollectionType() ) {
|
else if ( type instanceof CollectionType ) {
|
||||||
cascadeCollection(
|
cascadeCollection(
|
||||||
action,
|
action,
|
||||||
cascadePoint,
|
cascadePoint,
|
||||||
|
@ -485,7 +486,7 @@ public final class Cascade {
|
||||||
}
|
}
|
||||||
|
|
||||||
//cascade to current collection elements
|
//cascade to current collection elements
|
||||||
if ( elemType.isEntityType() || elemType.isAnyType() || elemType.isComponentType() ) {
|
if ( elemType instanceof EntityType || elemType instanceof AnyType || elemType instanceof ComponentType ) {
|
||||||
cascadeCollectionElements(
|
cascadeCollectionElements(
|
||||||
action,
|
action,
|
||||||
elementsCascadePoint,
|
elementsCascadePoint,
|
||||||
|
@ -514,7 +515,7 @@ public final class Cascade {
|
||||||
final CascadeStyle style,
|
final CascadeStyle style,
|
||||||
final T anything,
|
final T anything,
|
||||||
final boolean isCascadeDeleteEnabled) {
|
final boolean isCascadeDeleteEnabled) {
|
||||||
final String entityName = type.isEntityType()
|
final String entityName = type instanceof EntityType
|
||||||
? ( (EntityType) type ).getAssociatedEntityName()
|
? ( (EntityType) type ).getAssociatedEntityName()
|
||||||
: null;
|
: null;
|
||||||
if ( style.reallyDoCascade( action ) ) {
|
if ( style.reallyDoCascade( action ) ) {
|
||||||
|
@ -578,7 +579,7 @@ public final class Cascade {
|
||||||
|
|
||||||
final boolean deleteOrphans = style.hasOrphanDelete()
|
final boolean deleteOrphans = style.hasOrphanDelete()
|
||||||
&& action.deleteOrphans()
|
&& action.deleteOrphans()
|
||||||
&& elemType.isEntityType()
|
&& elemType instanceof EntityType
|
||||||
&& child instanceof PersistentCollection
|
&& child instanceof PersistentCollection
|
||||||
// a newly instantiated collection can't have orphans
|
// a newly instantiated collection can't have orphans
|
||||||
&& ! ( (PersistentCollection<?>) child ).isNewlyInstantiated();
|
&& ! ( (PersistentCollection<?>) child ).isNewlyInstantiated();
|
||||||
|
|
|
@ -17,7 +17,8 @@ import org.hibernate.internal.util.StringHelper;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.proxy.HibernateProxy;
|
import org.hibernate.proxy.HibernateProxy;
|
||||||
import org.hibernate.proxy.LazyInitializer;
|
import org.hibernate.proxy.LazyInitializer;
|
||||||
import org.hibernate.type.CompositeType;
|
import org.hibernate.type.AnyType;
|
||||||
|
import org.hibernate.type.ComponentType;
|
||||||
import org.hibernate.type.EntityType;
|
import org.hibernate.type.EntityType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
|
||||||
|
@ -91,7 +92,7 @@ public final class ForeignKeys {
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
returnedValue = null;
|
returnedValue = null;
|
||||||
}
|
}
|
||||||
else if ( type.isEntityType() ) {
|
else if ( type instanceof EntityType ) {
|
||||||
final EntityType entityType = (EntityType) type;
|
final EntityType entityType = (EntityType) type;
|
||||||
if ( entityType.isOneToOne() ) {
|
if ( entityType.isOneToOne() ) {
|
||||||
returnedValue = value;
|
returnedValue = value;
|
||||||
|
@ -113,11 +114,11 @@ public final class ForeignKeys {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( type.isAnyType() ) {
|
else if ( type instanceof AnyType ) {
|
||||||
returnedValue = isNullifiable( null, value ) ? null : value;
|
returnedValue = isNullifiable( null, value ) ? null : value;
|
||||||
}
|
}
|
||||||
else if ( type.isComponentType() ) {
|
else if ( type instanceof ComponentType ) {
|
||||||
final CompositeType actype = (CompositeType) type;
|
final ComponentType actype = (ComponentType) type;
|
||||||
final Object[] subvalues = actype.getPropertyValues( value, session );
|
final Object[] subvalues = actype.getPropertyValues( value, session );
|
||||||
final Type[] subtypes = actype.getSubtypes();
|
final Type[] subtypes = actype.getSubtypes();
|
||||||
final String[] subPropertyNames = actype.getPropertyNames();
|
final String[] subPropertyNames = actype.getPropertyNames();
|
||||||
|
@ -159,7 +160,7 @@ public final class ForeignKeys {
|
||||||
final Type type) {
|
final Type type) {
|
||||||
if ( isDelete &&
|
if ( isDelete &&
|
||||||
value == LazyPropertyInitializer.UNFETCHED_PROPERTY &&
|
value == LazyPropertyInitializer.UNFETCHED_PROPERTY &&
|
||||||
type.isEntityType() &&
|
type instanceof EntityType &&
|
||||||
!session.getPersistenceContextInternal().isNullifiableEntityKeysEmpty() ) {
|
!session.getPersistenceContextInternal().isNullifiableEntityKeysEmpty() ) {
|
||||||
// IMPLEMENTATION NOTE: If cascade-remove was mapped for the attribute,
|
// IMPLEMENTATION NOTE: If cascade-remove was mapped for the attribute,
|
||||||
// then value should have been initialized previously, when the remove operation was
|
// then value should have been initialized previously, when the remove operation was
|
||||||
|
@ -406,7 +407,7 @@ public final class ForeignKeys {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( type.isEntityType() ) {
|
if ( type instanceof EntityType ) {
|
||||||
final EntityType entityType = (EntityType) type;
|
final EntityType entityType = (EntityType) type;
|
||||||
if ( !isNullable
|
if ( !isNullable
|
||||||
&& !entityType.isOneToOne()
|
&& !entityType.isOneToOne()
|
||||||
|
@ -414,13 +415,13 @@ public final class ForeignKeys {
|
||||||
nonNullableTransientEntities.add( propertyName, value );
|
nonNullableTransientEntities.add( propertyName, value );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( type.isAnyType() ) {
|
else if ( type instanceof AnyType ) {
|
||||||
if ( !isNullable && nullifier.isNullifiable( null, value ) ) {
|
if ( !isNullable && nullifier.isNullifiable( null, value ) ) {
|
||||||
nonNullableTransientEntities.add( propertyName, value );
|
nonNullableTransientEntities.add( propertyName, value );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( type.isComponentType() ) {
|
else if ( type instanceof ComponentType ) {
|
||||||
final CompositeType actype = (CompositeType) type;
|
final ComponentType actype = (ComponentType) type;
|
||||||
final boolean[] subValueNullability = actype.getPropertyNullability();
|
final boolean[] subValueNullability = actype.getPropertyNullability();
|
||||||
if ( subValueNullability != null ) {
|
if ( subValueNullability != null ) {
|
||||||
final String[] subPropertyNames = actype.getPropertyNames();
|
final String[] subPropertyNames = actype.getPropertyNames();
|
||||||
|
|
|
@ -15,7 +15,9 @@ import org.hibernate.engine.spi.CascadingActions;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.generator.Generator;
|
import org.hibernate.generator.Generator;
|
||||||
|
import org.hibernate.type.AnyType;
|
||||||
import org.hibernate.type.CollectionType;
|
import org.hibernate.type.CollectionType;
|
||||||
|
import org.hibernate.type.ComponentType;
|
||||||
import org.hibernate.type.CompositeType;
|
import org.hibernate.type.CompositeType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
|
||||||
|
@ -143,16 +145,19 @@ public final class Nullability {
|
||||||
* @throws HibernateException error while getting subcomponent values
|
* @throws HibernateException error while getting subcomponent values
|
||||||
*/
|
*/
|
||||||
private String checkSubElementsNullability(Type propertyType, Object value) throws HibernateException {
|
private String checkSubElementsNullability(Type propertyType, Object value) throws HibernateException {
|
||||||
if ( propertyType.isComponentType() ) {
|
if ( propertyType instanceof AnyType ) {
|
||||||
return checkComponentNullability( value, (CompositeType) propertyType );
|
return checkComponentNullability( value, (AnyType) propertyType );
|
||||||
|
}
|
||||||
|
if ( propertyType instanceof ComponentType ) {
|
||||||
|
return checkComponentNullability( value, (ComponentType) propertyType );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( propertyType.isCollectionType() ) {
|
if ( propertyType instanceof CollectionType ) {
|
||||||
// persistent collections may have components
|
// persistent collections may have components
|
||||||
final CollectionType collectionType = (CollectionType) propertyType;
|
final CollectionType collectionType = (CollectionType) propertyType;
|
||||||
final Type collectionElementType = collectionType.getElementType( session.getFactory() );
|
final Type collectionElementType = collectionType.getElementType( session.getFactory() );
|
||||||
|
|
||||||
if ( collectionElementType.isComponentType() ) {
|
if ( collectionElementType instanceof ComponentType || collectionElementType instanceof AnyType ) {
|
||||||
// check for all components values in the collection
|
// check for all components values in the collection
|
||||||
final CompositeType componentType = (CompositeType) collectionElementType;
|
final CompositeType componentType = (CompositeType) collectionElementType;
|
||||||
final Iterator<?> itr = CascadingActions.getLoadedElementsIterator( session, collectionType, value );
|
final Iterator<?> itr = CascadingActions.getLoadedElementsIterator( session, collectionType, value );
|
||||||
|
@ -188,7 +193,7 @@ public final class Nullability {
|
||||||
//
|
//
|
||||||
// The more correct fix would be to cascade saves of the many-to-any elements before the Nullability checking
|
// The more correct fix would be to cascade saves of the many-to-any elements before the Nullability checking
|
||||||
|
|
||||||
if ( compositeType.isAnyType() ) {
|
if ( compositeType instanceof AnyType ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import java.util.Map;
|
||||||
import org.hibernate.internal.CoreLogging;
|
import org.hibernate.internal.CoreLogging;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
import org.hibernate.type.BagType;
|
import org.hibernate.type.BagType;
|
||||||
|
import org.hibernate.type.CollectionType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,7 +83,7 @@ public class FetchProfile {
|
||||||
public void addFetch(final Fetch fetch) {
|
public void addFetch(final Fetch fetch) {
|
||||||
final String fetchAssociactionRole = fetch.getAssociation().getRole();
|
final String fetchAssociactionRole = fetch.getAssociation().getRole();
|
||||||
final Type associationType = fetch.getAssociation().getOwner().getPropertyType( fetch.getAssociation().getAssociationPath() );
|
final Type associationType = fetch.getAssociation().getOwner().getPropertyType( fetch.getAssociation().getAssociationPath() );
|
||||||
if ( associationType.isCollectionType() ) {
|
if ( associationType instanceof CollectionType ) {
|
||||||
LOG.tracev( "Handling request to add collection fetch [{0}]", fetchAssociactionRole );
|
LOG.tracev( "Handling request to add collection fetch [{0}]", fetchAssociactionRole );
|
||||||
|
|
||||||
// couple of things for which to account in the case of collection
|
// couple of things for which to account in the case of collection
|
||||||
|
|
|
@ -53,7 +53,7 @@ import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.proxy.HibernateProxy;
|
import org.hibernate.proxy.HibernateProxy;
|
||||||
import org.hibernate.proxy.LazyInitializer;
|
import org.hibernate.proxy.LazyInitializer;
|
||||||
import org.hibernate.type.CollectionType;
|
import org.hibernate.type.CollectionType;
|
||||||
import org.hibernate.type.CompositeType;
|
import org.hibernate.type.ComponentType;
|
||||||
import org.hibernate.type.EntityType;
|
import org.hibernate.type.EntityType;
|
||||||
import org.hibernate.type.ForeignKeyDirection;
|
import org.hibernate.type.ForeignKeyDirection;
|
||||||
import org.hibernate.type.OneToOneType;
|
import org.hibernate.type.OneToOneType;
|
||||||
|
@ -1151,7 +1151,10 @@ public class ActionQueue {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addDirectDependency(Type type, Object value, IdentityHashMap<Object, InsertInfo> insertInfosByEntity) {
|
private void addDirectDependency(Type type, Object value, IdentityHashMap<Object, InsertInfo> insertInfosByEntity) {
|
||||||
if ( type.isEntityType() && value != null ) {
|
if ( value == null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ( type instanceof EntityType ) {
|
||||||
final EntityType entityType = (EntityType) type;
|
final EntityType entityType = (EntityType) type;
|
||||||
final InsertInfo insertInfo = insertInfosByEntity.get(value);
|
final InsertInfo insertInfo = insertInfosByEntity.get(value);
|
||||||
if (insertInfo != null) {
|
if (insertInfo != null) {
|
||||||
|
@ -1171,7 +1174,7 @@ public class ActionQueue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( type.isCollectionType() && value != null ) {
|
else if ( type instanceof CollectionType ) {
|
||||||
CollectionType collectionType = (CollectionType) type;
|
CollectionType collectionType = (CollectionType) type;
|
||||||
final PluralAttributeMapping pluralAttributeMapping = insertAction.getSession()
|
final PluralAttributeMapping pluralAttributeMapping = insertAction.getSession()
|
||||||
.getFactory()
|
.getFactory()
|
||||||
|
@ -1194,9 +1197,9 @@ public class ActionQueue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( type.isComponentType() && value != null ) {
|
else if ( type instanceof ComponentType ) {
|
||||||
// Support recursive checks of composite type properties for associations and collections.
|
// Support recursive checks of composite type properties for associations and collections.
|
||||||
CompositeType compositeType = (CompositeType) type;
|
ComponentType compositeType = (ComponentType) type;
|
||||||
final SharedSessionContractImplementor session = insertAction.getSession();
|
final SharedSessionContractImplementor session = insertAction.getSession();
|
||||||
Object[] componentValues = compositeType.getPropertyValues( value, session );
|
Object[] componentValues = compositeType.getPropertyValues( value, session );
|
||||||
for ( int j = 0; j < componentValues.length; ++j ) {
|
for ( int j = 0; j < componentValues.length; ++j ) {
|
||||||
|
|
|
@ -359,7 +359,7 @@ public class CascadingActions {
|
||||||
EntityPersister persister,
|
EntityPersister persister,
|
||||||
Type propertyType,
|
Type propertyType,
|
||||||
int propertyIndex) {
|
int propertyIndex) {
|
||||||
if ( propertyType.isEntityType() ) {
|
if ( propertyType instanceof EntityType ) {
|
||||||
Object child = persister.getValue( parent, propertyIndex );
|
Object child = persister.getValue( parent, propertyIndex );
|
||||||
if ( child != null
|
if ( child != null
|
||||||
&& !isInManagedState( child, session )
|
&& !isInManagedState( child, session )
|
||||||
|
|
|
@ -10,7 +10,9 @@ import org.hibernate.HibernateException;
|
||||||
import org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer;
|
import org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer;
|
||||||
import org.hibernate.event.spi.EventSource;
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
|
import org.hibernate.type.AnyType;
|
||||||
import org.hibernate.type.CollectionType;
|
import org.hibernate.type.CollectionType;
|
||||||
|
import org.hibernate.type.ComponentType;
|
||||||
import org.hibernate.type.CompositeType;
|
import org.hibernate.type.CompositeType;
|
||||||
import org.hibernate.type.EntityType;
|
import org.hibernate.type.EntityType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
@ -87,15 +89,18 @@ public abstract class AbstractVisitor {
|
||||||
*/
|
*/
|
||||||
final Object processValue(Object value, Type type) throws HibernateException {
|
final Object processValue(Object value, Type type) throws HibernateException {
|
||||||
|
|
||||||
if ( type.isCollectionType() ) {
|
if ( type instanceof CollectionType ) {
|
||||||
//even process null collections
|
//even process null collections
|
||||||
return processCollection( value, (CollectionType) type );
|
return processCollection( value, (CollectionType) type );
|
||||||
}
|
}
|
||||||
else if ( type.isEntityType() ) {
|
else if ( type instanceof EntityType ) {
|
||||||
return processEntity( value, (EntityType) type );
|
return processEntity( value, (EntityType) type );
|
||||||
}
|
}
|
||||||
else if ( type.isComponentType() ) {
|
else if ( type instanceof ComponentType ) {
|
||||||
return processComponent( value, (CompositeType) type );
|
return processComponent( value, (ComponentType) type );
|
||||||
|
}
|
||||||
|
else if ( type instanceof AnyType ) {
|
||||||
|
return processComponent( value, (AnyType) type );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -47,6 +47,7 @@ import org.hibernate.property.access.internal.PropertyAccessStrategyBackRefImpl;
|
||||||
import org.hibernate.proxy.HibernateProxy;
|
import org.hibernate.proxy.HibernateProxy;
|
||||||
import org.hibernate.proxy.LazyInitializer;
|
import org.hibernate.proxy.LazyInitializer;
|
||||||
import org.hibernate.type.CollectionType;
|
import org.hibernate.type.CollectionType;
|
||||||
|
import org.hibernate.type.ComponentType;
|
||||||
import org.hibernate.type.CompositeType;
|
import org.hibernate.type.CompositeType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
import org.hibernate.type.TypeHelper;
|
import org.hibernate.type.TypeHelper;
|
||||||
|
@ -133,15 +134,15 @@ public class DefaultDeleteEventListener implements DeleteEventListener, Callback
|
||||||
private static void deleteOwnedCollections(Type type, Object key, EventSource session) {
|
private static void deleteOwnedCollections(Type type, Object key, EventSource session) {
|
||||||
MappingMetamodelImplementor mappingMetamodel = session.getFactory().getMappingMetamodel();
|
MappingMetamodelImplementor mappingMetamodel = session.getFactory().getMappingMetamodel();
|
||||||
ActionQueue actionQueue = session.getActionQueue();
|
ActionQueue actionQueue = session.getActionQueue();
|
||||||
if ( type.isCollectionType() ) {
|
if ( type instanceof CollectionType ) {
|
||||||
String role = ( (CollectionType) type ).getRole();
|
String role = ( (CollectionType) type ).getRole();
|
||||||
CollectionPersister persister = mappingMetamodel.getCollectionDescriptor(role);
|
CollectionPersister persister = mappingMetamodel.getCollectionDescriptor(role);
|
||||||
if ( !persister.isInverse() ) {
|
if ( !persister.isInverse() ) {
|
||||||
actionQueue.addAction( new CollectionRemoveAction( persister, key, session ) );
|
actionQueue.addAction( new CollectionRemoveAction( persister, key, session ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( type.isComponentType() ) {
|
else if ( type instanceof ComponentType ) {
|
||||||
Type[] subtypes = ( (CompositeType) type ).getSubtypes();
|
Type[] subtypes = ( (ComponentType) type ).getSubtypes();
|
||||||
for ( Type subtype : subtypes ) {
|
for ( Type subtype : subtypes ) {
|
||||||
deleteOwnedCollections( subtype, key, session );
|
deleteOwnedCollections( subtype, key, session );
|
||||||
}
|
}
|
||||||
|
@ -453,7 +454,7 @@ public class DefaultDeleteEventListener implements DeleteEventListener, Callback
|
||||||
final String[] propertyNames = persister.getPropertyNames();
|
final String[] propertyNames = persister.getPropertyNames();
|
||||||
final BytecodeEnhancementMetadata enhancementMetadata = persister.getBytecodeEnhancementMetadata();
|
final BytecodeEnhancementMetadata enhancementMetadata = persister.getBytecodeEnhancementMetadata();
|
||||||
for ( int i = 0; i < types.length; i++) {
|
for ( int i = 0; i < types.length; i++) {
|
||||||
if ( types[i].isCollectionType() && !enhancementMetadata.isAttributeLoaded( parent, propertyNames[i] ) ) {
|
if ( types[i] instanceof CollectionType && !enhancementMetadata.isAttributeLoaded( parent, propertyNames[i] ) ) {
|
||||||
final CollectionType collectionType = (CollectionType) types[i];
|
final CollectionType collectionType = (CollectionType) types[i];
|
||||||
final CollectionPersister collectionDescriptor = persister.getFactory().getMappingMetamodel()
|
final CollectionPersister collectionDescriptor = persister.getFactory().getMappingMetamodel()
|
||||||
.getCollectionDescriptor( collectionType.getRole() );
|
.getCollectionDescriptor( collectionType.getRole() );
|
||||||
|
|
|
@ -40,7 +40,9 @@ import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.proxy.HibernateProxy;
|
import org.hibernate.proxy.HibernateProxy;
|
||||||
import org.hibernate.proxy.LazyInitializer;
|
import org.hibernate.proxy.LazyInitializer;
|
||||||
import org.hibernate.stat.spi.StatisticsImplementor;
|
import org.hibernate.stat.spi.StatisticsImplementor;
|
||||||
|
import org.hibernate.type.AnyType;
|
||||||
import org.hibernate.type.CollectionType;
|
import org.hibernate.type.CollectionType;
|
||||||
|
import org.hibernate.type.ComponentType;
|
||||||
import org.hibernate.type.CompositeType;
|
import org.hibernate.type.CompositeType;
|
||||||
import org.hibernate.type.EntityType;
|
import org.hibernate.type.EntityType;
|
||||||
import org.hibernate.type.ForeignKeyDirection;
|
import org.hibernate.type.ForeignKeyDirection;
|
||||||
|
@ -161,14 +163,14 @@ public class DefaultMergeEventListener
|
||||||
originalId = persister.getIdentifier( entity, source );
|
originalId = persister.getIdentifier( entity, source );
|
||||||
if ( originalId != null ) {
|
if ( originalId != null ) {
|
||||||
final EntityKey entityKey;
|
final EntityKey entityKey;
|
||||||
if ( persister.getIdentifierType().isComponentType() ) {
|
if ( persister.getIdentifierType() instanceof ComponentType ) {
|
||||||
/*
|
/*
|
||||||
this is needed in case of composite id containing an association with a generated identifier, in such a case
|
this is needed in case of composite id containing an association with a generated identifier, in such a case
|
||||||
generating the EntityKey will cause a NPE when trying to get the hashcode of the null id
|
generating the EntityKey will cause a NPE when trying to get the hashcode of the null id
|
||||||
*/
|
*/
|
||||||
copiedId = copyCompositeTypeId(
|
copiedId = copyCompositeTypeId(
|
||||||
originalId,
|
originalId,
|
||||||
(CompositeType) persister.getIdentifierType(),
|
(ComponentType) persister.getIdentifierType(),
|
||||||
source,
|
source,
|
||||||
copiedAlready
|
copiedAlready
|
||||||
);
|
);
|
||||||
|
@ -247,7 +249,7 @@ public class DefaultMergeEventListener
|
||||||
final Object[] copyValues = compositeType.getPropertyValues( idCopy );
|
final Object[] copyValues = compositeType.getPropertyValues( idCopy );
|
||||||
for ( int i = 0; i < subtypes.length; i++ ) {
|
for ( int i = 0; i < subtypes.length; i++ ) {
|
||||||
final Type subtype = subtypes[i];
|
final Type subtype = subtypes[i];
|
||||||
if ( subtype.isEntityType() ) {
|
if ( subtype instanceof EntityType ) {
|
||||||
// the value of the copy in the MergeContext has the id assigned
|
// the value of the copy in the MergeContext has the id assigned
|
||||||
final Object o = mergeContext.get( propertyValues[i] );
|
final Object o = mergeContext.get( propertyValues[i] );
|
||||||
if ( o != null ) {
|
if ( o != null ) {
|
||||||
|
@ -257,8 +259,11 @@ public class DefaultMergeEventListener
|
||||||
copyValues[i] = subtype.deepCopy( propertyValues[i], sessionFactory );
|
copyValues[i] = subtype.deepCopy( propertyValues[i], sessionFactory );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( subtype.isComponentType() ) {
|
else if ( subtype instanceof AnyType ) {
|
||||||
copyValues[i] = copyCompositeTypeId( propertyValues[i], (CompositeType) subtype, session, mergeContext );
|
copyValues[i] = copyCompositeTypeId( propertyValues[i], (AnyType) subtype, session, mergeContext );
|
||||||
|
}
|
||||||
|
else if ( subtype instanceof ComponentType ) {
|
||||||
|
copyValues[i] = copyCompositeTypeId( propertyValues[i], (ComponentType) subtype, session, mergeContext );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
copyValues[i] = subtype.deepCopy( propertyValues[i], sessionFactory );
|
copyValues[i] = subtype.deepCopy( propertyValues[i], sessionFactory );
|
||||||
|
|
|
@ -34,6 +34,7 @@ import org.hibernate.persister.collection.CollectionPersister;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.pretty.MessageHelper;
|
import org.hibernate.pretty.MessageHelper;
|
||||||
import org.hibernate.type.CollectionType;
|
import org.hibernate.type.CollectionType;
|
||||||
|
import org.hibernate.type.ComponentType;
|
||||||
import org.hibernate.type.CompositeType;
|
import org.hibernate.type.CompositeType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
|
||||||
|
@ -243,7 +244,7 @@ public class DefaultRefreshEventListener implements RefreshEventListener {
|
||||||
final SessionFactoryImplementor factory = source.getFactory();
|
final SessionFactoryImplementor factory = source.getFactory();
|
||||||
final MappingMetamodelImplementor metamodel = factory.getRuntimeMetamodels().getMappingMetamodel();
|
final MappingMetamodelImplementor metamodel = factory.getRuntimeMetamodels().getMappingMetamodel();
|
||||||
for ( Type type : types ) {
|
for ( Type type : types ) {
|
||||||
if ( type.isCollectionType() ) {
|
if ( type instanceof CollectionType ) {
|
||||||
final String role = ((CollectionType) type).getRole();
|
final String role = ((CollectionType) type).getRole();
|
||||||
CollectionPersister collectionPersister = metamodel.getCollectionDescriptor( role );
|
CollectionPersister collectionPersister = metamodel.getCollectionDescriptor( role );
|
||||||
if ( collectionPersister.hasCache() ) {
|
if ( collectionPersister.hasCache() ) {
|
||||||
|
@ -259,8 +260,9 @@ public class DefaultRefreshEventListener implements RefreshEventListener {
|
||||||
actionQueue.registerProcess( (success, session) -> cache.unlockItem( session, ck, lock ) );
|
actionQueue.registerProcess( (success, session) -> cache.unlockItem( session, ck, lock ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( type.isComponentType() ) {
|
else if ( type instanceof ComponentType ) {
|
||||||
CompositeType compositeType = (CompositeType) type;
|
// Only components can contain collections
|
||||||
|
ComponentType compositeType = (ComponentType) type;
|
||||||
evictCachedCollections( compositeType.getSubtypes(), id, source );
|
evictCachedCollections( compositeType.getSubtypes(), id, source );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class ForeignGenerator implements IdentifierGenerator, StandardGenerator
|
||||||
|
|
||||||
final EntityType foreignValueSourceType;
|
final EntityType foreignValueSourceType;
|
||||||
final Type propertyType = entityDescriptor.getPropertyType( propertyName );
|
final Type propertyType = entityDescriptor.getPropertyType( propertyName );
|
||||||
if ( propertyType.isEntityType() ) {
|
if ( propertyType instanceof EntityType ) {
|
||||||
// the normal case
|
// the normal case
|
||||||
foreignValueSourceType = (EntityType) propertyType;
|
foreignValueSourceType = (EntityType) propertyType;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,9 @@ import org.hibernate.property.access.spi.Setter;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
import org.hibernate.generator.Generator;
|
import org.hibernate.generator.Generator;
|
||||||
import org.hibernate.generator.GeneratorCreationContext;
|
import org.hibernate.generator.GeneratorCreationContext;
|
||||||
|
import org.hibernate.type.AnyType;
|
||||||
|
import org.hibernate.type.CollectionType;
|
||||||
|
import org.hibernate.type.ComponentType;
|
||||||
import org.hibernate.type.CompositeType;
|
import org.hibernate.type.CompositeType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
import org.hibernate.type.WrapperArrayHandling;
|
import org.hibernate.type.WrapperArrayHandling;
|
||||||
|
@ -150,10 +153,13 @@ public class Property implements Serializable, MetaAttributable {
|
||||||
|
|
||||||
public CascadeStyle getCascadeStyle() throws MappingException {
|
public CascadeStyle getCascadeStyle() throws MappingException {
|
||||||
final Type type = value.getType();
|
final Type type = value.getType();
|
||||||
if ( type.isComponentType() ) {
|
if ( type instanceof AnyType ) {
|
||||||
return getCompositeCascadeStyle( (CompositeType) type, cascade );
|
return getCascadeStyle( cascade );
|
||||||
}
|
}
|
||||||
else if ( type.isCollectionType() ) {
|
if ( type instanceof ComponentType ) {
|
||||||
|
return getCompositeCascadeStyle( (ComponentType) type, cascade );
|
||||||
|
}
|
||||||
|
else if ( type instanceof CollectionType ) {
|
||||||
return getCollectionCascadeStyle( ( (Collection) value ).getElement().getType(), cascade );
|
return getCollectionCascadeStyle( ( (Collection) value ).getElement().getType(), cascade );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -162,9 +168,15 @@ public class Property implements Serializable, MetaAttributable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CascadeStyle getCompositeCascadeStyle(CompositeType compositeType, String cascade) {
|
private static CascadeStyle getCompositeCascadeStyle(CompositeType compositeType, String cascade) {
|
||||||
if ( compositeType.isAnyType() ) {
|
if ( compositeType instanceof AnyType ) {
|
||||||
return getCascadeStyle( cascade );
|
return getCascadeStyle( cascade );
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return getCompositeCascadeStyle( (ComponentType) compositeType, cascade );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static CascadeStyle getCompositeCascadeStyle(ComponentType compositeType, String cascade) {
|
||||||
int length = compositeType.getSubtypes().length;
|
int length = compositeType.getSubtypes().length;
|
||||||
for ( int i=0; i<length; i++ ) {
|
for ( int i=0; i<length; i++ ) {
|
||||||
if ( compositeType.getCascadeStyle(i) != CascadeStyles.NONE ) {
|
if ( compositeType.getCascadeStyle(i) != CascadeStyles.NONE ) {
|
||||||
|
@ -175,8 +187,11 @@ public class Property implements Serializable, MetaAttributable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CascadeStyle getCollectionCascadeStyle(Type elementType, String cascade) {
|
private static CascadeStyle getCollectionCascadeStyle(Type elementType, String cascade) {
|
||||||
if ( elementType.isComponentType() ) {
|
if ( elementType instanceof AnyType ) {
|
||||||
return getCompositeCascadeStyle( (CompositeType) elementType, cascade );
|
return getCascadeStyle( cascade );
|
||||||
|
}
|
||||||
|
else if ( elementType instanceof ComponentType ) {
|
||||||
|
return getCompositeCascadeStyle( (ComponentType) elementType, cascade );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return getCascadeStyle( cascade );
|
return getCascadeStyle( cascade );
|
||||||
|
|
|
@ -57,6 +57,9 @@ import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.property.access.internal.PropertyAccessMapImpl;
|
import org.hibernate.property.access.internal.PropertyAccessMapImpl;
|
||||||
import org.hibernate.property.access.spi.Getter;
|
import org.hibernate.property.access.spi.Getter;
|
||||||
import org.hibernate.type.AnyType;
|
import org.hibernate.type.AnyType;
|
||||||
|
import org.hibernate.type.BasicType;
|
||||||
|
import org.hibernate.type.CollectionType;
|
||||||
|
import org.hibernate.type.ComponentType;
|
||||||
import org.hibernate.type.EntityType;
|
import org.hibernate.type.EntityType;
|
||||||
import org.hibernate.type.descriptor.java.JavaType;
|
import org.hibernate.type.descriptor.java.JavaType;
|
||||||
import org.hibernate.type.descriptor.java.spi.JavaTypeRegistry;
|
import org.hibernate.type.descriptor.java.spi.JavaTypeRegistry;
|
||||||
|
@ -409,7 +412,7 @@ public class AttributeFactory {
|
||||||
final org.hibernate.type.Type type = value.getType();
|
final org.hibernate.type.Type type = value.getType();
|
||||||
LOG.tracef( " Determined type [name=%s, class=%s]", type.getName(), type.getClass().getName() );
|
LOG.tracef( " Determined type [name=%s, class=%s]", type.getName(), type.getClass().getName() );
|
||||||
|
|
||||||
if ( type.isAnyType() ) {
|
if ( type instanceof AnyType ) {
|
||||||
return new SingularAttributeMetadataImpl<>(
|
return new SingularAttributeMetadataImpl<>(
|
||||||
propertyMapping,
|
propertyMapping,
|
||||||
attributeContext.getOwnerType(),
|
attributeContext.getOwnerType(),
|
||||||
|
@ -418,18 +421,17 @@ public class AttributeFactory {
|
||||||
context
|
context
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if ( type.isAssociationType() ) {
|
else if ( type instanceof EntityType ) {
|
||||||
// collection or entity
|
// entity
|
||||||
if ( type.isEntityType() ) {
|
return new SingularAttributeMetadataImpl<>(
|
||||||
// entity
|
propertyMapping,
|
||||||
return new SingularAttributeMetadataImpl<>(
|
attributeContext.getOwnerType(),
|
||||||
propertyMapping,
|
member,
|
||||||
attributeContext.getOwnerType(),
|
determineSingularAssociationClassification( member ),
|
||||||
member,
|
context
|
||||||
determineSingularAssociationClassification( member ),
|
);
|
||||||
context
|
}
|
||||||
);
|
else if ( type instanceof CollectionType ) {
|
||||||
}
|
|
||||||
// collection
|
// collection
|
||||||
if ( value instanceof Collection ) {
|
if ( value instanceof Collection ) {
|
||||||
final Collection collValue = (Collection) value;
|
final Collection collValue = (Collection) value;
|
||||||
|
@ -441,15 +443,15 @@ public class AttributeFactory {
|
||||||
// collection type
|
// collection type
|
||||||
final AttributeClassification elementClassification;
|
final AttributeClassification elementClassification;
|
||||||
final AttributeClassification attributeClassification;
|
final AttributeClassification attributeClassification;
|
||||||
if ( elementType.isAnyType() ) {
|
if ( elementType instanceof AnyType ) {
|
||||||
attributeClassification = AttributeClassification.ELEMENT_COLLECTION;
|
attributeClassification = AttributeClassification.ELEMENT_COLLECTION;
|
||||||
elementClassification = AttributeClassification.ANY;
|
elementClassification = AttributeClassification.ANY;
|
||||||
}
|
}
|
||||||
else if ( elementValue instanceof Component ) {
|
else if ( elementType instanceof ComponentType ) {
|
||||||
elementClassification = AttributeClassification.EMBEDDED;
|
elementClassification = AttributeClassification.EMBEDDED;
|
||||||
attributeClassification = AttributeClassification.ELEMENT_COLLECTION;
|
attributeClassification = AttributeClassification.ELEMENT_COLLECTION;
|
||||||
}
|
}
|
||||||
else if ( elementType.isAssociationType() ) {
|
else if ( elementType instanceof EntityType ) {
|
||||||
elementClassification = isManyToMany ?
|
elementClassification = isManyToMany ?
|
||||||
AttributeClassification.MANY_TO_MANY :
|
AttributeClassification.MANY_TO_MANY :
|
||||||
AttributeClassification.ONE_TO_MANY;
|
AttributeClassification.ONE_TO_MANY;
|
||||||
|
@ -467,13 +469,13 @@ public class AttributeFactory {
|
||||||
final Value keyValue = ( (Map) value ).getIndex();
|
final Value keyValue = ( (Map) value ).getIndex();
|
||||||
final org.hibernate.type.Type keyType = keyValue.getType();
|
final org.hibernate.type.Type keyType = keyValue.getType();
|
||||||
|
|
||||||
if ( keyType.isAnyType() ) {
|
if ( keyType instanceof AnyType ) {
|
||||||
indexClassification = AttributeClassification.ANY;
|
indexClassification = AttributeClassification.ANY;
|
||||||
}
|
}
|
||||||
else if ( keyValue instanceof Component ) {
|
else if ( keyType instanceof ComponentType ) {
|
||||||
indexClassification = AttributeClassification.EMBEDDED;
|
indexClassification = AttributeClassification.EMBEDDED;
|
||||||
}
|
}
|
||||||
else if ( keyType.isAssociationType() ) {
|
else if ( keyType instanceof EntityType ) {
|
||||||
indexClassification = AttributeClassification.MANY_TO_ONE;
|
indexClassification = AttributeClassification.MANY_TO_ONE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -516,7 +518,7 @@ public class AttributeFactory {
|
||||||
// );
|
// );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( propertyMapping.isComposite() ) {
|
else if ( type instanceof ComponentType ) {
|
||||||
// component
|
// component
|
||||||
return new SingularAttributeMetadataImpl<>(
|
return new SingularAttributeMetadataImpl<>(
|
||||||
propertyMapping,
|
propertyMapping,
|
||||||
|
@ -527,6 +529,7 @@ public class AttributeFactory {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
assert type instanceof BasicType<?>;
|
||||||
// basic type
|
// basic type
|
||||||
return new SingularAttributeMetadataImpl<>(
|
return new SingularAttributeMetadataImpl<>(
|
||||||
propertyMapping,
|
propertyMapping,
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.hibernate.mapping.Property;
|
||||||
import org.hibernate.metamodel.AttributeClassification;
|
import org.hibernate.metamodel.AttributeClassification;
|
||||||
import org.hibernate.metamodel.model.domain.ManagedDomainType;
|
import org.hibernate.metamodel.model.domain.ManagedDomainType;
|
||||||
import org.hibernate.metamodel.model.domain.internal.MapMember;
|
import org.hibernate.metamodel.model.domain.internal.MapMember;
|
||||||
|
import org.hibernate.type.CollectionType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
|
@ -88,7 +89,7 @@ public abstract class BaseAttributeMetadata<X, Y> implements AttributeMetadata<X
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPlural() {
|
public boolean isPlural() {
|
||||||
return propertyMapping.getType().isCollectionType();
|
return propertyMapping.getType() instanceof CollectionType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Property getPropertyMapping() {
|
public Property getPropertyMapping() {
|
||||||
|
|
|
@ -47,6 +47,7 @@ import org.hibernate.sql.results.graph.FetchParent;
|
||||||
import org.hibernate.sql.results.graph.collection.internal.EagerCollectionFetch;
|
import org.hibernate.sql.results.graph.collection.internal.EagerCollectionFetch;
|
||||||
import org.hibernate.sql.results.graph.entity.EntityFetch;
|
import org.hibernate.sql.results.graph.entity.EntityFetch;
|
||||||
import org.hibernate.sql.results.graph.entity.internal.EntityFetchJoinedImpl;
|
import org.hibernate.sql.results.graph.entity.internal.EntityFetchJoinedImpl;
|
||||||
|
import org.hibernate.type.ComponentType;
|
||||||
import org.hibernate.type.CompositeType;
|
import org.hibernate.type.CompositeType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
|
||||||
|
@ -382,8 +383,8 @@ public abstract class AbstractEntityCollectionPart implements EntityCollectionPa
|
||||||
propertyType = entityBinding.getIdentifierMapper().getType();
|
propertyType = entityBinding.getIdentifierMapper().getType();
|
||||||
}
|
}
|
||||||
if ( entityBinding.getIdentifierProperty() == null ) {
|
if ( entityBinding.getIdentifierProperty() == null ) {
|
||||||
final CompositeType compositeType;
|
final ComponentType compositeType;
|
||||||
if ( propertyType.isComponentType() && ( compositeType = (CompositeType) propertyType ).isEmbedded()
|
if ( propertyType instanceof ComponentType && ( compositeType = (ComponentType) propertyType ).isEmbedded()
|
||||||
&& compositeType.getPropertyNames().length == 1 ) {
|
&& compositeType.getPropertyNames().length == 1 ) {
|
||||||
ToOneAttributeMapping.addPrefixedPropertyPaths(
|
ToOneAttributeMapping.addPrefixedPropertyPaths(
|
||||||
targetKeyPropertyNames,
|
targetKeyPropertyNames,
|
||||||
|
@ -436,8 +437,8 @@ public abstract class AbstractEntityCollectionPart implements EntityCollectionPa
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
final Type propertyType = entityBinding.getRecursiveProperty( referencedPropertyName ).getType();
|
final Type propertyType = entityBinding.getRecursiveProperty( referencedPropertyName ).getType();
|
||||||
final CompositeType compositeType;
|
final ComponentType compositeType;
|
||||||
if ( propertyType.isComponentType() && ( compositeType = (CompositeType) propertyType ).isEmbedded()
|
if ( propertyType instanceof ComponentType && ( compositeType = (ComponentType) propertyType ).isEmbedded()
|
||||||
&& compositeType.getPropertyNames().length == 1 ) {
|
&& compositeType.getPropertyNames().length == 1 ) {
|
||||||
final Set<String> targetKeyPropertyNames = new HashSet<>( 2 );
|
final Set<String> targetKeyPropertyNames = new HashSet<>( 2 );
|
||||||
ToOneAttributeMapping.addPrefixedPropertyPaths(
|
ToOneAttributeMapping.addPrefixedPropertyPaths(
|
||||||
|
|
|
@ -16,7 +16,10 @@ import org.hibernate.persister.collection.AbstractCollectionPersister;
|
||||||
import org.hibernate.persister.collection.CollectionPersister;
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.sql.results.graph.FetchOptions;
|
import org.hibernate.sql.results.graph.FetchOptions;
|
||||||
|
import org.hibernate.type.AnyType;
|
||||||
import org.hibernate.type.AssociationType;
|
import org.hibernate.type.AssociationType;
|
||||||
|
import org.hibernate.type.CollectionType;
|
||||||
|
import org.hibernate.type.EntityType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
|
@ -40,7 +43,7 @@ public final class FetchOptionsHelper {
|
||||||
FetchMode mappingFetchMode,
|
FetchMode mappingFetchMode,
|
||||||
AssociationType type,
|
AssociationType type,
|
||||||
SessionFactoryImplementor sessionFactory) {
|
SessionFactoryImplementor sessionFactory) {
|
||||||
if ( !type.isEntityType() && !type.isCollectionType() ) {
|
if ( !( type instanceof EntityType ) && !( type instanceof CollectionType ) ) {
|
||||||
return FetchStyle.SELECT;
|
return FetchStyle.SELECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +51,7 @@ public final class FetchOptionsHelper {
|
||||||
return FetchStyle.JOIN;
|
return FetchStyle.JOIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( type.isEntityType() ) {
|
if ( type instanceof EntityType ) {
|
||||||
EntityPersister persister = (EntityPersister) type.getAssociatedJoinable( sessionFactory );
|
EntityPersister persister = (EntityPersister) type.getAssociatedJoinable( sessionFactory );
|
||||||
if ( persister.isBatchLoadable() ) {
|
if ( persister.isBatchLoadable() ) {
|
||||||
return FetchStyle.BATCH;
|
return FetchStyle.BATCH;
|
||||||
|
@ -116,11 +119,11 @@ public final class FetchOptionsHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isSubsequentSelectDelayed(AssociationType type, SessionFactoryImplementor sessionFactory) {
|
private static boolean isSubsequentSelectDelayed(AssociationType type, SessionFactoryImplementor sessionFactory) {
|
||||||
if ( type.isAnyType() ) {
|
if ( type instanceof AnyType ) {
|
||||||
// we'd need more context here. this is only kept as part of the property state on the owning entity
|
// we'd need more context here. this is only kept as part of the property state on the owning entity
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if ( type.isEntityType() ) {
|
else if ( type instanceof EntityType ) {
|
||||||
final EntityPersister entityPersister = (EntityPersister) type.getAssociatedJoinable( sessionFactory );
|
final EntityPersister entityPersister = (EntityPersister) type.getAssociatedJoinable( sessionFactory );
|
||||||
return entityPersister.getEntityMetamodel().isLazy();
|
return entityPersister.getEntityMetamodel().isLazy();
|
||||||
}
|
}
|
||||||
|
|
|
@ -743,7 +743,7 @@ public class MappingModelCreationHelper {
|
||||||
final ManagedMappingType keyDeclaringType;
|
final ManagedMappingType keyDeclaringType;
|
||||||
final String collectionTableName = ((AbstractCollectionPersister) collectionDescriptor).getTableName();
|
final String collectionTableName = ((AbstractCollectionPersister) collectionDescriptor).getTableName();
|
||||||
|
|
||||||
if ( collectionDescriptor.getElementType().isEntityType() ) {
|
if ( collectionDescriptor.getElementType() instanceof EntityType ) {
|
||||||
keyDeclaringType = ( (QueryableCollection) collectionDescriptor ).getElementPersister();
|
keyDeclaringType = ( (QueryableCollection) collectionDescriptor ).getElementPersister();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -427,8 +427,8 @@ public class ToOneAttributeMapping
|
||||||
propertyType = entityBinding.getIdentifierMapper().getType();
|
propertyType = entityBinding.getIdentifierMapper().getType();
|
||||||
}
|
}
|
||||||
if ( entityBinding.getIdentifierProperty() == null ) {
|
if ( entityBinding.getIdentifierProperty() == null ) {
|
||||||
final CompositeType compositeType;
|
final ComponentType compositeType;
|
||||||
if ( propertyType.isComponentType() && ( compositeType = (CompositeType) propertyType ).isEmbedded()
|
if ( propertyType instanceof ComponentType && ( compositeType = (ComponentType) propertyType ).isEmbedded()
|
||||||
&& compositeType.getPropertyNames().length == 1 ) {
|
&& compositeType.getPropertyNames().length == 1 ) {
|
||||||
this.targetKeyPropertyName = compositeType.getPropertyNames()[0];
|
this.targetKeyPropertyName = compositeType.getPropertyNames()[0];
|
||||||
addPrefixedPropertyPaths(
|
addPrefixedPropertyPaths(
|
||||||
|
@ -487,8 +487,8 @@ public class ToOneAttributeMapping
|
||||||
this.targetKeyPropertyNames = targetKeyPropertyNames;
|
this.targetKeyPropertyNames = targetKeyPropertyNames;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
final CompositeType compositeType;
|
final ComponentType compositeType;
|
||||||
if ( propertyType.isComponentType() && ( compositeType = (CompositeType) propertyType ).isEmbedded()
|
if ( propertyType instanceof ComponentType && ( compositeType = (ComponentType) propertyType ).isEmbedded()
|
||||||
&& compositeType.getPropertyNames().length == 1 ) {
|
&& compositeType.getPropertyNames().length == 1 ) {
|
||||||
final Set<String> targetKeyPropertyNames = new HashSet<>( 2 );
|
final Set<String> targetKeyPropertyNames = new HashSet<>( 2 );
|
||||||
this.targetKeyPropertyName = compositeType.getPropertyNames()[0];
|
this.targetKeyPropertyName = compositeType.getPropertyNames()[0];
|
||||||
|
@ -737,7 +737,7 @@ public class ToOneAttributeMapping
|
||||||
if ( prefix != null ) {
|
if ( prefix != null ) {
|
||||||
targetKeyPropertyNames.add( prefix );
|
targetKeyPropertyNames.add( prefix );
|
||||||
}
|
}
|
||||||
if ( type.isComponentType() ) {
|
if ( type instanceof ComponentType ) {
|
||||||
final ComponentType componentType = (ComponentType) type;
|
final ComponentType componentType = (ComponentType) type;
|
||||||
final String[] propertyNames = componentType.getPropertyNames();
|
final String[] propertyNames = componentType.getPropertyNames();
|
||||||
final Type[] componentTypeSubtypes = componentType.getSubtypes();
|
final Type[] componentTypeSubtypes = componentType.getSubtypes();
|
||||||
|
@ -752,7 +752,7 @@ public class ToOneAttributeMapping
|
||||||
addPrefixedPropertyNames( targetKeyPropertyNames, newPrefix, componentTypeSubtypes[i], factory );
|
addPrefixedPropertyNames( targetKeyPropertyNames, newPrefix, componentTypeSubtypes[i], factory );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( type.isEntityType() ) {
|
else if ( type instanceof EntityType ) {
|
||||||
final EntityType entityType = (EntityType) type;
|
final EntityType entityType = (EntityType) type;
|
||||||
final Type identifierOrUniqueKeyType = entityType.getIdentifierOrUniqueKeyType( factory );
|
final Type identifierOrUniqueKeyType = entityType.getIdentifierOrUniqueKeyType( factory );
|
||||||
final String propertyName;
|
final String propertyName;
|
||||||
|
|
|
@ -314,7 +314,7 @@ public class MappingMetamodelImpl extends QueryParameterBindingTypeResolverImpl
|
||||||
);
|
);
|
||||||
collectionPersisterMap.put( model.getRole(), persister );
|
collectionPersisterMap.put( model.getRole(), persister );
|
||||||
Type indexType = persister.getIndexType();
|
Type indexType = persister.getIndexType();
|
||||||
if ( indexType != null && indexType.isEntityType() && !indexType.isAnyType() ) {
|
if ( indexType instanceof org.hibernate.type.EntityType ) {
|
||||||
String entityName = ( (org.hibernate.type.EntityType) indexType ).getAssociatedEntityName();
|
String entityName = ( (org.hibernate.type.EntityType) indexType ).getAssociatedEntityName();
|
||||||
Set<String> roles = collectionRolesByEntityParticipant.get( entityName );
|
Set<String> roles = collectionRolesByEntityParticipant.get( entityName );
|
||||||
//noinspection Java8MapApi
|
//noinspection Java8MapApi
|
||||||
|
@ -325,7 +325,7 @@ public class MappingMetamodelImpl extends QueryParameterBindingTypeResolverImpl
|
||||||
roles.add( persister.getRole() );
|
roles.add( persister.getRole() );
|
||||||
}
|
}
|
||||||
Type elementType = persister.getElementType();
|
Type elementType = persister.getElementType();
|
||||||
if ( elementType.isEntityType() && !elementType.isAnyType() ) {
|
if ( elementType instanceof org.hibernate.type.EntityType ) {
|
||||||
String entityName = ( (org.hibernate.type.EntityType) elementType ).getAssociatedEntityName();
|
String entityName = ( (org.hibernate.type.EntityType) elementType ).getAssociatedEntityName();
|
||||||
Set<String> roles = collectionRolesByEntityParticipant.get( entityName );
|
Set<String> roles = collectionRolesByEntityParticipant.get( entityName );
|
||||||
//noinspection Java8MapApi
|
//noinspection Java8MapApi
|
||||||
|
|
|
@ -128,7 +128,9 @@ import org.hibernate.sql.model.jdbc.JdbcMutationOperation;
|
||||||
import org.hibernate.sql.results.graph.DomainResult;
|
import org.hibernate.sql.results.graph.DomainResult;
|
||||||
import org.hibernate.sql.results.graph.internal.ImmutableFetchList;
|
import org.hibernate.sql.results.graph.internal.ImmutableFetchList;
|
||||||
import org.hibernate.sql.results.internal.SqlSelectionImpl;
|
import org.hibernate.sql.results.internal.SqlSelectionImpl;
|
||||||
|
import org.hibernate.type.AnyType;
|
||||||
import org.hibernate.type.CollectionType;
|
import org.hibernate.type.CollectionType;
|
||||||
|
import org.hibernate.type.ComponentType;
|
||||||
import org.hibernate.type.CompositeType;
|
import org.hibernate.type.CompositeType;
|
||||||
import org.hibernate.type.EntityType;
|
import org.hibernate.type.EntityType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
@ -336,7 +338,7 @@ public abstract class AbstractCollectionPersister
|
||||||
|
|
||||||
// ELEMENT
|
// ELEMENT
|
||||||
|
|
||||||
if ( elementType.isEntityType() ) {
|
if ( elementType instanceof EntityType ) {
|
||||||
String entityName = ( (EntityType) elementType ).getAssociatedEntityName();
|
String entityName = ( (EntityType) elementType ).getAssociatedEntityName();
|
||||||
elementPersister = creationContext.getDomainModel().getEntityDescriptor( entityName );
|
elementPersister = creationContext.getDomainModel().getEntityDescriptor( entityName );
|
||||||
// NativeSQL: collect element column and auto-aliases
|
// NativeSQL: collect element column and auto-aliases
|
||||||
|
@ -387,7 +389,7 @@ public abstract class AbstractCollectionPersister
|
||||||
creationContext.getFunctionRegistry()
|
creationContext.getFunctionRegistry()
|
||||||
);
|
);
|
||||||
elementColumnIsGettable[j] = true;
|
elementColumnIsGettable[j] = true;
|
||||||
if ( elementType.isComponentType() ) {
|
if ( elementType instanceof ComponentType || elementType instanceof AnyType ) {
|
||||||
// Implements desired behavior specifically for @ElementCollection mappings.
|
// Implements desired behavior specifically for @ElementCollection mappings.
|
||||||
elementColumnIsSettable[j] = columnInsertability[j];
|
elementColumnIsSettable[j] = columnInsertability[j];
|
||||||
}
|
}
|
||||||
|
@ -503,7 +505,7 @@ public abstract class AbstractCollectionPersister
|
||||||
elementClass = null; // elementType.returnedClass();
|
elementClass = null; // elementType.returnedClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( elementType.isComponentType() ) {
|
if ( elementType instanceof ComponentType || elementType instanceof AnyType ) {
|
||||||
elementPropertyMapping = new CompositeElementPropertyMapping(
|
elementPropertyMapping = new CompositeElementPropertyMapping(
|
||||||
elementColumnNames,
|
elementColumnNames,
|
||||||
elementColumnReaders,
|
elementColumnReaders,
|
||||||
|
@ -513,7 +515,7 @@ public abstract class AbstractCollectionPersister
|
||||||
creationContext.getMetadata()
|
creationContext.getMetadata()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if ( !elementType.isEntityType() ) {
|
else if ( !( elementType instanceof EntityType ) ) {
|
||||||
elementPropertyMapping = new ElementPropertyMapping( elementColumnNames, elementType );
|
elementPropertyMapping = new ElementPropertyMapping( elementColumnNames, elementType );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1411,7 +1413,7 @@ public abstract class AbstractCollectionPersister
|
||||||
collectionPropertyColumnAliases.put( aliasName, columnAliases );
|
collectionPropertyColumnAliases.put( aliasName, columnAliases );
|
||||||
|
|
||||||
//TODO: this code is almost certainly obsolete and can be removed
|
//TODO: this code is almost certainly obsolete and can be removed
|
||||||
if ( type.isComponentType() ) {
|
if ( type instanceof ComponentType || type instanceof AnyType ) {
|
||||||
CompositeType ct = (CompositeType) type;
|
CompositeType ct = (CompositeType) type;
|
||||||
String[] propertyNames = ct.getPropertyNames();
|
String[] propertyNames = ct.getPropertyNames();
|
||||||
for ( int i = 0; i < propertyNames.length; i++ ) {
|
for ( int i = 0; i < propertyNames.length; i++ ) {
|
||||||
|
|
|
@ -51,6 +51,7 @@ import org.hibernate.sql.model.ast.builder.CollectionRowDeleteBuilder;
|
||||||
import org.hibernate.sql.model.ast.builder.TableInsertBuilderStandard;
|
import org.hibernate.sql.model.ast.builder.TableInsertBuilderStandard;
|
||||||
import org.hibernate.sql.model.ast.builder.TableUpdateBuilderStandard;
|
import org.hibernate.sql.model.ast.builder.TableUpdateBuilderStandard;
|
||||||
import org.hibernate.sql.model.jdbc.JdbcMutationOperation;
|
import org.hibernate.sql.model.jdbc.JdbcMutationOperation;
|
||||||
|
import org.hibernate.type.EntityType;
|
||||||
|
|
||||||
import static org.hibernate.sql.model.ModelMutationLogging.MODEL_MUTATION_LOGGER;
|
import static org.hibernate.sql.model.ModelMutationLogging.MODEL_MUTATION_LOGGER;
|
||||||
|
|
||||||
|
@ -701,7 +702,7 @@ public class BasicCollectionPersister extends AbstractCollectionPersister {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isManyToMany() {
|
public boolean isManyToMany() {
|
||||||
return elementType.isEntityType(); //instanceof AssociationType;
|
return elementType instanceof EntityType; //instanceof AssociationType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -283,6 +283,7 @@ import org.hibernate.type.AnyType;
|
||||||
import org.hibernate.type.AssociationType;
|
import org.hibernate.type.AssociationType;
|
||||||
import org.hibernate.type.BasicType;
|
import org.hibernate.type.BasicType;
|
||||||
import org.hibernate.type.CollectionType;
|
import org.hibernate.type.CollectionType;
|
||||||
|
import org.hibernate.type.ComponentType;
|
||||||
import org.hibernate.type.CompositeType;
|
import org.hibernate.type.CompositeType;
|
||||||
import org.hibernate.type.EntityType;
|
import org.hibernate.type.EntityType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
@ -902,7 +903,7 @@ public abstract class AbstractEntityPersister
|
||||||
// 2) have no associations.
|
// 2) have no associations.
|
||||||
// Eventually we want to be a little more lenient with associations.
|
// Eventually we want to be a little more lenient with associations.
|
||||||
for ( Type type : getSubclassPropertyTypeClosure() ) {
|
for ( Type type : getSubclassPropertyTypeClosure() ) {
|
||||||
if ( type.isAssociationType() ) {
|
if ( type instanceof AnyType || type instanceof CollectionType || type instanceof EntityType ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1445,7 +1446,7 @@ public abstract class AbstractEntityPersister
|
||||||
|
|
||||||
if ( hasCollections() ) {
|
if ( hasCollections() ) {
|
||||||
final Type type = getPropertyType( fieldName );
|
final Type type = getPropertyType( fieldName );
|
||||||
if ( type.isCollectionType() ) {
|
if ( type instanceof CollectionType ) {
|
||||||
// we have a condition where a collection attribute is being access via enhancement:
|
// we have a condition where a collection attribute is being access via enhancement:
|
||||||
// we can circumvent all the rest and just return the PersistentCollection
|
// we can circumvent all the rest and just return the PersistentCollection
|
||||||
final CollectionType collectionType = (CollectionType) type;
|
final CollectionType collectionType = (CollectionType) type;
|
||||||
|
@ -2245,7 +2246,7 @@ public abstract class AbstractEntityPersister
|
||||||
// // performance op to avoid the array search
|
// // performance op to avoid the array search
|
||||||
// return 0;
|
// return 0;
|
||||||
// }
|
// }
|
||||||
// else if ( type.isCollectionType() ) {
|
// else if ( type instanceof CollectionType ) {
|
||||||
// // properly handle property-ref-based associations
|
// // properly handle property-ref-based associations
|
||||||
// rootPropertyName = assocType.getLHSPropertyName();
|
// rootPropertyName = assocType.getLHSPropertyName();
|
||||||
// }
|
// }
|
||||||
|
@ -6444,9 +6445,9 @@ public abstract class AbstractEntityPersister
|
||||||
}
|
}
|
||||||
|
|
||||||
// aliases for composite-id's
|
// aliases for composite-id's
|
||||||
if ( getIdentifierType().isComponentType() ) {
|
if ( getIdentifierType() instanceof ComponentType ) {
|
||||||
// Fetch embedded identifiers property names from the "virtual" identifier component
|
// Fetch embedded identifiers property names from the "virtual" identifier component
|
||||||
final CompositeType componentId = (CompositeType) getIdentifierType();
|
final ComponentType componentId = (ComponentType) getIdentifierType();
|
||||||
final String[] idPropertyNames = componentId.getPropertyNames();
|
final String[] idPropertyNames = componentId.getPropertyNames();
|
||||||
final String[] idAliases = getIdentifierAliases();
|
final String[] idAliases = getIdentifierAliases();
|
||||||
final String[] idColumnNames = getIdentifierColumnNames();
|
final String[] idColumnNames = getIdentifierColumnNames();
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.hibernate.sql.Template;
|
||||||
import org.hibernate.type.AnyType;
|
import org.hibernate.type.AnyType;
|
||||||
import org.hibernate.type.AssociationType;
|
import org.hibernate.type.AssociationType;
|
||||||
import org.hibernate.type.CollectionType;
|
import org.hibernate.type.CollectionType;
|
||||||
|
import org.hibernate.type.ComponentType;
|
||||||
import org.hibernate.type.CompositeType;
|
import org.hibernate.type.CompositeType;
|
||||||
import org.hibernate.type.EntityType;
|
import org.hibernate.type.EntityType;
|
||||||
import org.hibernate.type.ManyToOneType;
|
import org.hibernate.type.ManyToOneType;
|
||||||
|
@ -282,7 +283,7 @@ public abstract class AbstractPropertyMapping implements PropertyMapping {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( type.isAssociationType() ) {
|
if ( type instanceof AnyType || type instanceof CollectionType || type instanceof EntityType ) {
|
||||||
AssociationType actype = (AssociationType) type;
|
AssociationType actype = (AssociationType) type;
|
||||||
if ( actype.useLHSPrimaryKey() ) {
|
if ( actype.useLHSPrimaryKey() ) {
|
||||||
columns = getIdentifierColumnNames();
|
columns = getIdentifierColumnNames();
|
||||||
|
@ -308,8 +309,20 @@ public abstract class AbstractPropertyMapping implements PropertyMapping {
|
||||||
addPropertyPath( path, type, columns, columnReaders, columnReaderTemplates, formulaTemplates, factory );
|
addPropertyPath( path, type, columns, columnReaders, columnReaderTemplates, formulaTemplates, factory );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( type.isComponentType() ) {
|
if ( type instanceof AnyType ) {
|
||||||
CompositeType actype = (CompositeType) type;
|
AnyType actype = (AnyType) type;
|
||||||
|
initComponentPropertyPaths(
|
||||||
|
path,
|
||||||
|
actype,
|
||||||
|
columns,
|
||||||
|
columnReaders,
|
||||||
|
columnReaderTemplates,
|
||||||
|
formulaTemplates,
|
||||||
|
factory
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if ( type instanceof ComponentType ) {
|
||||||
|
ComponentType actype = (ComponentType) type;
|
||||||
initComponentPropertyPaths(
|
initComponentPropertyPaths(
|
||||||
path,
|
path,
|
||||||
actype,
|
actype,
|
||||||
|
@ -331,7 +344,7 @@ public abstract class AbstractPropertyMapping implements PropertyMapping {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( type.isEntityType() ) {
|
else if ( type instanceof EntityType ) {
|
||||||
initIdentifierPropertyPaths(
|
initIdentifierPropertyPaths(
|
||||||
path,
|
path,
|
||||||
(EntityType) type,
|
(EntityType) type,
|
||||||
|
|
|
@ -409,7 +409,7 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
|
||||||
String entitySuffix) {
|
String entitySuffix) {
|
||||||
final CollectionPersister collectionPersister = collectionReturn.getPluralAttribute().getCollectionDescriptor();
|
final CollectionPersister collectionPersister = collectionReturn.getPluralAttribute().getCollectionDescriptor();
|
||||||
final String[] elementColumnAliases;
|
final String[] elementColumnAliases;
|
||||||
if ( collectionPersister.getElementType().isEntityType() ) {
|
if ( collectionPersister.getElementType() instanceof EntityType ) {
|
||||||
final Loadable elementPersister = (Loadable) ( ( QueryableCollection ) collectionPersister).getElementPersister();
|
final Loadable elementPersister = (Loadable) ( ( QueryableCollection ) collectionPersister).getElementPersister();
|
||||||
final String[] propertyNames = elementPersister.getPropertyNames();
|
final String[] propertyNames = elementPersister.getPropertyNames();
|
||||||
final String[] identifierAliases = elementPersister.getIdentifierAliases( entitySuffix );
|
final String[] identifierAliases = elementPersister.getIdentifierAliases( entitySuffix );
|
||||||
|
@ -568,13 +568,13 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
|
||||||
SQLLoadable ownerPersister = ( SQLLoadable ) alias2Persister.get( ownerAlias );
|
SQLLoadable ownerPersister = ( SQLLoadable ) alias2Persister.get( ownerAlias );
|
||||||
Type returnType = ownerPersister.getPropertyType( fetchReturn.getFetchableName() );
|
Type returnType = ownerPersister.getPropertyType( fetchReturn.getFetchableName() );
|
||||||
|
|
||||||
if ( returnType.isCollectionType() ) {
|
if ( returnType instanceof CollectionType ) {
|
||||||
String role = ownerPersister.getEntityName() + '.' + fetchReturn.getFetchableName();
|
String role = ownerPersister.getEntityName() + '.' + fetchReturn.getFetchableName();
|
||||||
Map<String, String[]> propertyResultsMap = Collections.emptyMap();//fetchReturn.getPropertyResultsMap()
|
Map<String, String[]> propertyResultsMap = Collections.emptyMap();//fetchReturn.getPropertyResultsMap()
|
||||||
addCollection( role, alias, propertyResultsMap );
|
addCollection( role, alias, propertyResultsMap );
|
||||||
// collectionOwnerAliases.add( ownerAlias );
|
// collectionOwnerAliases.add( ownerAlias );
|
||||||
}
|
}
|
||||||
else if ( returnType.isEntityType() ) {
|
else if ( returnType instanceof EntityType ) {
|
||||||
EntityType eType = ( EntityType ) returnType;
|
EntityType eType = ( EntityType ) returnType;
|
||||||
String returnEntityName = eType.getAssociatedEntityName();
|
String returnEntityName = eType.getAssociatedEntityName();
|
||||||
SQLLoadable persister = getSQLLoadable( returnEntityName );
|
SQLLoadable persister = getSQLLoadable( returnEntityName );
|
||||||
|
@ -634,7 +634,7 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
|
||||||
// }
|
// }
|
||||||
// for ( CollectionPersister persister : alias2CollectionPersister.values() ) {
|
// for ( CollectionPersister persister : alias2CollectionPersister.values() ) {
|
||||||
// final Type elementType = persister.getElementType();
|
// final Type elementType = persister.getElementType();
|
||||||
// if ( elementType.isEntityType() && ! elementType.isAnyType() ) {
|
// if ( elementType instanceof EntityType && ! elementType instanceof AnyType ) {
|
||||||
// final Joinable joinable = ( (EntityType) elementType ).getAssociatedJoinable( factory );
|
// final Joinable joinable = ( (EntityType) elementType ).getAssociatedJoinable( factory );
|
||||||
// Collections.addAll( spaces, (String[]) ( (EntityPersister) joinable ).getQuerySpaces() );
|
// Collections.addAll( spaces, (String[]) ( (EntityPersister) joinable ).getQuerySpaces() );
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -43,6 +43,7 @@ import org.hibernate.sql.results.jdbc.spi.JdbcValuesMapping;
|
||||||
import org.hibernate.sql.results.spi.RowReader;
|
import org.hibernate.sql.results.spi.RowReader;
|
||||||
import org.hibernate.sql.results.spi.RowTransformer;
|
import org.hibernate.sql.results.spi.RowTransformer;
|
||||||
import org.hibernate.stat.spi.StatisticsImplementor;
|
import org.hibernate.stat.spi.StatisticsImplementor;
|
||||||
|
import org.hibernate.type.EntityType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
|
@ -268,7 +269,7 @@ public class ResultsHelper {
|
||||||
);
|
);
|
||||||
|
|
||||||
boolean isPutFromLoad = true;
|
boolean isPutFromLoad = true;
|
||||||
if ( collectionDescriptor.getElementType().isAssociationType() ) {
|
if ( collectionDescriptor.getElementType() instanceof EntityType ) {
|
||||||
final EntityPersister entityPersister = ( (QueryableCollection) collectionDescriptor ).getElementPersister();
|
final EntityPersister entityPersister = ( (QueryableCollection) collectionDescriptor ).getElementPersister();
|
||||||
for ( Object id : entry.getState() ) {
|
for ( Object id : entry.getState() ) {
|
||||||
if ( persistenceContext.wasInsertedDuringTransaction( entityPersister, id ) ) {
|
if ( persistenceContext.wasInsertedDuringTransaction( entityPersister, id ) ) {
|
||||||
|
|
|
@ -20,8 +20,12 @@ import org.hibernate.tuple.entity.EntityBasedAssociationAttribute;
|
||||||
import org.hibernate.tuple.entity.EntityBasedBasicAttribute;
|
import org.hibernate.tuple.entity.EntityBasedBasicAttribute;
|
||||||
import org.hibernate.tuple.entity.EntityBasedCompositionAttribute;
|
import org.hibernate.tuple.entity.EntityBasedCompositionAttribute;
|
||||||
import org.hibernate.tuple.entity.VersionProperty;
|
import org.hibernate.tuple.entity.VersionProperty;
|
||||||
|
import org.hibernate.type.AnyType;
|
||||||
import org.hibernate.type.AssociationType;
|
import org.hibernate.type.AssociationType;
|
||||||
|
import org.hibernate.type.CollectionType;
|
||||||
|
import org.hibernate.type.ComponentType;
|
||||||
import org.hibernate.type.CompositeType;
|
import org.hibernate.type.CompositeType;
|
||||||
|
import org.hibernate.type.EntityType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -218,22 +222,19 @@ public final class PropertyFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static NonIdentifierAttributeNature decode(Type type) {
|
private static NonIdentifierAttributeNature decode(Type type) {
|
||||||
if ( type.isAssociationType() ) {
|
if ( type instanceof CollectionType ) {
|
||||||
|
return NonIdentifierAttributeNature.COLLECTION;
|
||||||
if ( type.isComponentType() ) {
|
}
|
||||||
// an any type is both an association and a composite...
|
else if ( type instanceof EntityType ) {
|
||||||
return NonIdentifierAttributeNature.ANY;
|
return NonIdentifierAttributeNature.ENTITY;
|
||||||
}
|
}
|
||||||
|
else if ( type instanceof AnyType ) {
|
||||||
return type.isCollectionType()
|
return NonIdentifierAttributeNature.ANY;
|
||||||
? NonIdentifierAttributeNature.COLLECTION
|
}
|
||||||
: NonIdentifierAttributeNature.ENTITY;
|
else if ( type instanceof ComponentType ) {
|
||||||
|
return NonIdentifierAttributeNature.COMPOSITE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ( type.isComponentType() ) {
|
|
||||||
return NonIdentifierAttributeNature.COMPOSITE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NonIdentifierAttributeNature.BASIC;
|
return NonIdentifierAttributeNature.BASIC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -552,7 +552,7 @@ public class EntityMetamodel implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean indicatesCollection(Type type) {
|
private static boolean indicatesCollection(Type type) {
|
||||||
if ( type.isCollectionType() ) {
|
if ( type instanceof CollectionType ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if ( type.isComponentType() ) {
|
else if ( type.isComponentType() ) {
|
||||||
|
@ -567,7 +567,7 @@ public class EntityMetamodel implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean indicatesOwnedCollection(Type type, MetadataImplementor metadata) {
|
private static boolean indicatesOwnedCollection(Type type, MetadataImplementor metadata) {
|
||||||
if ( type.isCollectionType() ) {
|
if ( type instanceof CollectionType ) {
|
||||||
String role = ( (CollectionType) type ).getRole();
|
String role = ( (CollectionType) type ).getRole();
|
||||||
return !metadata.getCollectionBinding( role ).isInverse();
|
return !metadata.getCollectionBinding( role ).isInverse();
|
||||||
}
|
}
|
||||||
|
|
|
@ -476,7 +476,7 @@ public abstract class CollectionType extends AbstractType implements Association
|
||||||
|
|
||||||
QueryableCollection collectionPersister = (QueryableCollection) factory.getRuntimeMetamodels().getMappingMetamodel().getCollectionDescriptor( role );
|
QueryableCollection collectionPersister = (QueryableCollection) factory.getRuntimeMetamodels().getMappingMetamodel().getCollectionDescriptor( role );
|
||||||
|
|
||||||
if ( !collectionPersister.getElementType().isEntityType() ) {
|
if ( !( collectionPersister.getElementType() instanceof EntityType ) ) {
|
||||||
throw new MappingException(
|
throw new MappingException(
|
||||||
"collection was not an association: " +
|
"collection was not an association: " +
|
||||||
collectionPersister.getRole()
|
collectionPersister.getRole()
|
||||||
|
|
|
@ -491,7 +491,7 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
// we need to dig a little deeper, as that property might also be
|
// we need to dig a little deeper, as that property might also be
|
||||||
// an entity type, in which case we need to resolve its identifier
|
// an entity type, in which case we need to resolve its identifier
|
||||||
final Type type = entityPersister.getPropertyType( uniqueKeyPropertyName );
|
final Type type = entityPersister.getPropertyType( uniqueKeyPropertyName );
|
||||||
if ( type.isEntityType() ) {
|
if ( type instanceof EntityType ) {
|
||||||
return ( (EntityType) type ).getIdentifier( propertyValue, session );
|
return ( (EntityType) type ).getIdentifier( propertyValue, session );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,7 +515,7 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
// we need to dig a little deeper, as that property might also be
|
// we need to dig a little deeper, as that property might also be
|
||||||
// an entity type, in which case we need to resolve its identifier
|
// an entity type, in which case we need to resolve its identifier
|
||||||
Type type = entityPersister.getPropertyType( uniqueKeyPropertyName );
|
Type type = entityPersister.getPropertyType( uniqueKeyPropertyName );
|
||||||
if ( type.isEntityType() ) {
|
if ( type instanceof EntityType ) {
|
||||||
propertyValue = ( (EntityType) type ).getIdentifier( propertyValue, sessionFactory );
|
propertyValue = ( (EntityType) type ).getIdentifier( propertyValue, sessionFactory );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -639,7 +639,7 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Type type = factory.getReferencedPropertyType( getAssociatedEntityName(), uniqueKeyPropertyName );
|
Type type = factory.getReferencedPropertyType( getAssociatedEntityName(), uniqueKeyPropertyName );
|
||||||
if ( type.isEntityType() ) {
|
if ( type instanceof EntityType ) {
|
||||||
type = ( (EntityType) type ).getIdentifierOrUniqueKeyType( factory );
|
type = ( (EntityType) type ).getIdentifierOrUniqueKeyType( factory );
|
||||||
}
|
}
|
||||||
return type;
|
return type;
|
||||||
|
|
|
@ -192,7 +192,7 @@ public class TypeHelper {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
final Type type = types[i];
|
final Type type = types[i];
|
||||||
if ( type.isComponentType() ) {
|
if ( type instanceof AnyType || type instanceof ComponentType ) {
|
||||||
final CompositeType compositeType = (CompositeType) type;
|
final CompositeType compositeType = (CompositeType) type;
|
||||||
// need to extract the component values and check for subtype replacements...
|
// need to extract the component values and check for subtype replacements...
|
||||||
final Type[] subtypes = compositeType.getSubtypes();
|
final Type[] subtypes = compositeType.getSubtypes();
|
||||||
|
@ -226,11 +226,11 @@ public class TypeHelper {
|
||||||
}
|
}
|
||||||
copied[i] = target[i];
|
copied[i] = target[i];
|
||||||
}
|
}
|
||||||
else if ( !type.isAssociationType() ) {
|
else if ( type instanceof CollectionType || type instanceof EntityType ) {
|
||||||
copied[i] = target[i];
|
copied[i] = types[i].replace( currentOriginal, target[i], session, owner, copyCache, foreignKeyDirection );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
copied[i] = types[i].replace( currentOriginal, target[i], session, owner, copyCache, foreignKeyDirection );
|
copied[i] = target[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,7 +200,7 @@ public class BasicCollectionMapper<T extends Collection> extends AbstractCollect
|
||||||
// Currently the tuple is { owner_id, entity_id, rev } and so having this special
|
// Currently the tuple is { owner_id, entity_id, rev } and so having this special
|
||||||
// treatment is critical to avoid HHH-13080.
|
// treatment is critical to avoid HHH-13080.
|
||||||
//
|
//
|
||||||
if ( elementType.isEntityType() && !revisionTypeInId ) {
|
if ( elementType instanceof EntityType && !revisionTypeInId ) {
|
||||||
|
|
||||||
// This is a short-circuit to check for reference equality only.
|
// This is a short-circuit to check for reference equality only.
|
||||||
// There is no need to delegate to the identifier if the objects are reference equal.
|
// There is no need to delegate to the identifier if the objects are reference equal.
|
||||||
|
|
|
@ -432,7 +432,7 @@ public class ValidityAuditStrategy implements AuditStrategy {
|
||||||
final Type propertyType = session.getSessionFactory()
|
final Type propertyType = session.getSessionFactory()
|
||||||
.getMappingMetamodel()
|
.getMappingMetamodel()
|
||||||
.getEntityDescriptor( entityName ).getPropertyType( propertyName );
|
.getEntityDescriptor( entityName ).getPropertyType( propertyName );
|
||||||
if ( propertyType.isCollectionType() ) {
|
if ( propertyType instanceof CollectionType ) {
|
||||||
final CollectionType collectionType = (CollectionType) propertyType;
|
final CollectionType collectionType = (CollectionType) propertyType;
|
||||||
final Type collectionElementType = collectionType.getElementType( session.getSessionFactory() );
|
final Type collectionElementType = collectionType.getElementType( session.getSessionFactory() );
|
||||||
if ( collectionElementType instanceof ComponentType ) {
|
if ( collectionElementType instanceof ComponentType ) {
|
||||||
|
|
Loading…
Reference in New Issue