HHH-13587 Make StatefulPersistenceContext#nonlazyCollections a lazily initialized field
This commit is contained in:
parent
690a8d5520
commit
dbbc24c2e1
|
@ -163,8 +163,6 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
entityEntryContext = new EntityEntryContext( this );
|
entityEntryContext = new EntityEntryContext( this );
|
||||||
collectionsByKey = new HashMap<>( INIT_COLL_SIZE );
|
collectionsByKey = new HashMap<>( INIT_COLL_SIZE );
|
||||||
arrayHolders = new IdentityHashMap<>( INIT_COLL_SIZE );
|
arrayHolders = new IdentityHashMap<>( INIT_COLL_SIZE );
|
||||||
|
|
||||||
nonlazyCollections = new ArrayList<>( INIT_COLL_SIZE );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ConcurrentMap<EntityKey, Object> getOrInitializeProxiesByKey() {
|
private ConcurrentMap<EntityKey, Object> getOrInitializeProxiesByKey() {
|
||||||
|
@ -252,6 +250,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
parentsByChild = null;
|
parentsByChild = null;
|
||||||
entitySnapshotsByKey.clear();
|
entitySnapshotsByKey.clear();
|
||||||
collectionsByKey.clear();
|
collectionsByKey.clear();
|
||||||
|
nonlazyCollections = null;
|
||||||
collectionEntries = null;
|
collectionEntries = null;
|
||||||
unownedCollections = null;
|
unownedCollections = null;
|
||||||
proxiesByKey = null;
|
proxiesByKey = null;
|
||||||
|
@ -952,6 +951,9 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addNonLazyCollection(PersistentCollection collection) {
|
public void addNonLazyCollection(PersistentCollection collection) {
|
||||||
|
if ( nonlazyCollections == null ) {
|
||||||
|
nonlazyCollections = new ArrayList<>( INIT_COLL_SIZE );
|
||||||
|
}
|
||||||
nonlazyCollections.add( collection );
|
nonlazyCollections.add( collection );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -965,7 +967,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
loadCounter++;
|
loadCounter++;
|
||||||
try {
|
try {
|
||||||
int size;
|
int size;
|
||||||
while ( ( size = nonlazyCollections.size() ) > 0 ) {
|
while ( nonlazyCollections != null && ( size = nonlazyCollections.size() ) > 0 ) {
|
||||||
//note that each iteration of the loop may add new elements
|
//note that each iteration of the loop may add new elements
|
||||||
nonlazyCollections.remove( size - 1 ).forceInitialization();
|
nonlazyCollections.remove( size - 1 ).forceInitialization();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue