From 00acb1f21363dfa33ef19ae06c07e48abdca40fb Mon Sep 17 00:00:00 2001 From: Davide D'Alto Date: Fri, 15 May 2020 10:47:49 +0100 Subject: [PATCH] HHH-13997 Use functions for the creation of ActionQueue and PersistenceContext --- .../org/hibernate/internal/SessionImpl.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java index f33ad21018..5de54a21a2 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java @@ -28,6 +28,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; +import java.util.function.Function; import java.util.function.Supplier; import javax.persistence.CacheRetrieveMode; import javax.persistence.CacheStoreMode; @@ -219,10 +220,17 @@ public class SessionImpl private transient GraphImplementor fetchGraphLoadContext; public SessionImpl(SessionFactoryImpl factory, SessionCreationOptions options) { + this( factory, options, StatefulPersistenceContext::new, ActionQueue::new ); + } + + public SessionImpl( + SessionFactoryImpl factory, SessionCreationOptions options, + Function persistenceContextFunction, + Function actionQueueFunction) { super( factory, options ); - this.persistenceContext = createPersistenceContext(); - this.actionQueue = createActionQueue(); + this.persistenceContext = persistenceContextFunction.apply( this ); + this.actionQueue = actionQueueFunction.apply( this ); this.autoClear = options.shouldAutoClear(); this.autoClose = options.shouldAutoClose(); @@ -269,14 +277,6 @@ 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; }