From ae1016a1c4df3f655ad57b79dc591faa8154d490 Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Wed, 19 Jun 2019 21:46:42 +0100 Subject: [PATCH] HHH-13444 Remove ignored EntityMode field from CollectionKey --- .../loading/internal/CollectionLoadContext.java | 6 ++---- .../org/hibernate/engine/spi/CollectionKey.java | 14 ++++++-------- .../java/org/hibernate/type/CollectionType.java | 6 ++---- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/loading/internal/CollectionLoadContext.java b/hibernate-core/src/main/java/org/hibernate/engine/loading/internal/CollectionLoadContext.java index 3160964374..c76d6014d9 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/loading/internal/CollectionLoadContext.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/loading/internal/CollectionLoadContext.java @@ -93,8 +93,7 @@ public class CollectionLoadContext { * @return The loading collection (see discussion above). */ public PersistentCollection getLoadingCollection(final CollectionPersister persister, final Serializable key) { - final EntityMode em = persister.getOwnerEntityPersister().getEntityMetamodel().getEntityMode(); - final CollectionKey collectionKey = new CollectionKey( persister, key, em ); + final CollectionKey collectionKey = new CollectionKey( persister, key ); if ( LOG.isTraceEnabled() ) { LOG.tracev( "Starting attempt to find loading collection [{0}]", MessageHelper.collectionInfoString( persister.getRole(), key ) ); @@ -179,8 +178,7 @@ public class CollectionLoadContext { session.getPersistenceContext().addUnownedCollection( new CollectionKey( persister, - lce.getKey(), - persister.getOwnerEntityPersister().getEntityMetamodel().getEntityMode() + lce.getKey() ), lce.getCollection() ); diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/CollectionKey.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/CollectionKey.java index 091539351e..5db19a612d 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/CollectionKey.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/CollectionKey.java @@ -27,32 +27,33 @@ public final class CollectionKey implements Serializable { private final Type keyType; private final SessionFactoryImplementor factory; private final int hashCode; - private EntityMode entityMode; public CollectionKey(CollectionPersister persister, Serializable key) { this( persister.getRole(), key, persister.getKeyType(), - persister.getOwnerEntityPersister().getEntityMetamodel().getEntityMode(), persister.getFactory() ); } + /** + * The EntityMode parameter is now ignored. Use the other constructor. + * @deprecated Use {@link #CollectionKey(CollectionPersister, Serializable)} + */ + @Deprecated public CollectionKey(CollectionPersister persister, Serializable key, EntityMode em) { - this( persister.getRole(), key, persister.getKeyType(), em, persister.getFactory() ); + this( persister.getRole(), key, persister.getKeyType(), persister.getFactory() ); } private CollectionKey( String role, Serializable key, Type keyType, - EntityMode entityMode, SessionFactoryImplementor factory) { this.role = role; this.key = key; this.keyType = keyType; - this.entityMode = entityMode; this.factory = factory; //cache the hash-code this.hashCode = generateHashCode(); @@ -65,7 +66,6 @@ public final class CollectionKey implements Serializable { return result; } - public String getRole() { return role; } @@ -112,7 +112,6 @@ public final class CollectionKey implements Serializable { oos.writeObject( role ); oos.writeObject( key ); oos.writeObject( keyType ); - oos.writeObject( entityMode.toString() ); } /** @@ -134,7 +133,6 @@ public final class CollectionKey implements Serializable { (String) ois.readObject(), (Serializable) ois.readObject(), (Type) ois.readObject(), - EntityMode.parse( (String) ois.readObject() ), (session == null ? null : session.getFactory()) ); } diff --git a/hibernate-core/src/main/java/org/hibernate/type/CollectionType.java b/hibernate-core/src/main/java/org/hibernate/type/CollectionType.java index 9e6519cc53..42c19d7552 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/CollectionType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/CollectionType.java @@ -20,7 +20,6 @@ import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; -import org.hibernate.EntityMode; import org.hibernate.Hibernate; import org.hibernate.HibernateException; import org.hibernate.MappingException; @@ -771,14 +770,13 @@ public abstract class CollectionType extends AbstractType implements Association final CollectionPersister persister = getPersister( session ); final PersistenceContext persistenceContext = session.getPersistenceContext(); - final EntityMode entityMode = persister.getOwnerEntityPersister().getEntityMode(); // check if collection is currently being loaded PersistentCollection collection = persistenceContext.getLoadContexts().locateLoadingCollection( persister, key ); if ( collection == null ) { - final CollectionKey collectionKey = new CollectionKey( persister, key, entityMode ); + final CollectionKey collectionKey = new CollectionKey( persister, key ); // check if it is already completely loaded, but unowned collection = persistenceContext.useUnownedCollection( collectionKey ); @@ -804,7 +802,7 @@ public abstract class CollectionType extends AbstractType implements Association } if ( hasHolder() ) { - session.getPersistenceContext().addCollectionHolder( collection ); + persistenceContext.addCollectionHolder( collection ); } if ( LOG.isTraceEnabled() ) {