HHH-13587 Allocate StatefulPersistenceContext#nullAssociations lazily

This commit is contained in:
Sanne Grinovero 2019-08-17 15:53:07 +01:00 committed by Sanne Grinovero
parent 5bbf417c52
commit aae670b9b3
1 changed files with 5 additions and 3 deletions

View File

@ -176,7 +176,6 @@ public class StatefulPersistenceContext implements PersistenceContext {
collectionsByKey = new HashMap<>( INIT_COLL_SIZE );
arrayHolders = new IdentityHashMap<>( INIT_COLL_SIZE );
nullAssociations = new HashSet<>( INIT_COLL_SIZE );
nonlazyCollections = new ArrayList<>( INIT_COLL_SIZE );
}
@ -1359,16 +1358,19 @@ public class StatefulPersistenceContext implements PersistenceContext {
@Override
public void addNullProperty(EntityKey ownerKey, String propertyName) {
if ( nullAssociations == null ) {
nullAssociations = new HashSet<>( INIT_COLL_SIZE );
}
nullAssociations.add( new AssociationKey( ownerKey, propertyName ) );
}
@Override
public boolean isPropertyNull(EntityKey ownerKey, String propertyName) {
return nullAssociations.contains( new AssociationKey( ownerKey, propertyName ) );
return nullAssociations != null && nullAssociations.contains( new AssociationKey( ownerKey, propertyName ) );
}
private void clearNullProperties() {
nullAssociations.clear();
nullAssociations = null;
}
@Override