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