HHH-13997 : Add methods to SessionImpl and StatefulPersistenceContext; make Loader method protected
* Change visibility for Loader#registerNonExists * Methods for creating PersistenceContext and ActionQueue * Add StatefulPersistenceContext#initializeNonLazyCollections(Consumer<PersistentCollection> initializeAction)
This commit is contained in:
parent
2d7022ecec
commit
9cd2236fd3
|
@ -23,6 +23,7 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.hibernate.AssertionFailure;
|
||||
|
@ -984,6 +985,10 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
|||
|
||||
@Override
|
||||
public void initializeNonLazyCollections() throws HibernateException {
|
||||
initializeNonLazyCollections( PersistentCollection::forceInitialization );
|
||||
}
|
||||
|
||||
protected void initializeNonLazyCollections(Consumer<PersistentCollection> initializeAction ) {
|
||||
if ( loadCounter == 0 ) {
|
||||
LOG.trace( "Initializing non-lazy collections" );
|
||||
|
||||
|
@ -994,7 +999,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
|||
int size;
|
||||
while ( nonlazyCollections != null && ( size = nonlazyCollections.size() ) > 0 ) {
|
||||
//note that each iteration of the loop may add new elements
|
||||
nonlazyCollections.remove( size - 1 ).forceInitialization();
|
||||
initializeAction.accept( nonlazyCollections.remove( size - 1 ) );
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
|
|
@ -221,8 +221,8 @@ public class SessionImpl
|
|||
public SessionImpl(SessionFactoryImpl factory, SessionCreationOptions options) {
|
||||
super( factory, options );
|
||||
|
||||
this.actionQueue = new ActionQueue( this );
|
||||
this.persistenceContext = new StatefulPersistenceContext( this );
|
||||
this.persistenceContext = createPersistenceContext();
|
||||
this.actionQueue = createActionQueue();
|
||||
|
||||
this.autoClear = options.shouldAutoClear();
|
||||
this.autoClose = options.shouldAutoClose();
|
||||
|
@ -269,6 +269,14 @@ public class SessionImpl
|
|||
}
|
||||
}
|
||||
|
||||
protected StatefulPersistenceContext createPersistenceContext() {
|
||||
return new StatefulPersistenceContext( this );
|
||||
}
|
||||
|
||||
protected ActionQueue createActionQueue() {
|
||||
return new ActionQueue( this );
|
||||
}
|
||||
|
||||
private LockOptions getLockOptionsForRead() {
|
||||
return this.lockOptions == null ? fastSessionServices.defaultLockOptions : this.lockOptions;
|
||||
}
|
||||
|
|
|
@ -1298,7 +1298,7 @@ public abstract class Loader {
|
|||
* result set, register the fact that the the object is missing with the
|
||||
* session.
|
||||
*/
|
||||
private void registerNonExists(
|
||||
protected void registerNonExists(
|
||||
final EntityKey[] keys,
|
||||
final Loadable[] persisters,
|
||||
final SharedSessionContractImplementor session) {
|
||||
|
|
Loading…
Reference in New Issue