Skip to content

Commit

Permalink
HHH-13444 Remove ignored EntityMode field from CollectionKey
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanne committed Jun 19, 2019
1 parent 7f326b1 commit ae1016a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
Expand Up @@ -93,8 +93,7 @@ public LoadContexts getLoadContext() {
* @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 ) );
Expand Down Expand Up @@ -179,8 +178,7 @@ else if ( lce.getResultSet() == resultSet && lce.getPersister() == persister ) {
session.getPersistenceContext().addUnownedCollection(
new CollectionKey(
persister,
lce.getKey(),
persister.getOwnerEntityPersister().getEntityMetamodel().getEntityMode()
lce.getKey()
),
lce.getCollection()
);
Expand Down
Expand Up @@ -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();
Expand All @@ -65,7 +66,6 @@ private int generateHashCode() {
return result;
}


public String getRole() {
return role;
}
Expand Down Expand Up @@ -112,7 +112,6 @@ public void serialize(ObjectOutputStream oos) throws IOException {
oos.writeObject( role );
oos.writeObject( key );
oos.writeObject( keyType );
oos.writeObject( entityMode.toString() );
}

/**
Expand All @@ -134,7 +133,6 @@ public static CollectionKey deserialize(
(String) ois.readObject(),
(Serializable) ois.readObject(),
(Type) ois.readObject(),
EntityMode.parse( (String) ois.readObject() ),
(session == null ? null : session.getFactory())
);
}
Expand Down
Expand Up @@ -20,7 +20,6 @@
import java.util.SortedMap;
import java.util.TreeMap;

import org.hibernate.EntityMode;
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
Expand Down Expand Up @@ -771,14 +770,13 @@ public Object getCollection(Serializable key, SharedSessionContractImplementor s

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 );

Expand All @@ -804,7 +802,7 @@ else if ( eager ) {
}

if ( hasHolder() ) {
session.getPersistenceContext().addCollectionHolder( collection );
persistenceContext.addCollectionHolder( collection );
}

if ( LOG.isTraceEnabled() ) {
Expand Down

0 comments on commit ae1016a

Please sign in to comment.