From 38d9f3738cbae514ba79dcb4db0c3949482e43bb Mon Sep 17 00:00:00 2001 From: Davide D'Alto Date: Thu, 14 May 2020 10:32:40 +0100 Subject: [PATCH] HHH-14024 Allow the creation of a different QueryPlanCache --- .../org/hibernate/internal/SessionFactoryImpl.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java index 4bb5553dd4..e8dc089d1c 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java @@ -18,6 +18,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.TimeZone; +import java.util.function.Function; import java.util.function.Supplier; import javax.naming.Reference; import javax.naming.StringRefAddr; @@ -195,9 +196,13 @@ public class SessionFactoryImpl implements SessionFactoryImplementor { private final transient SessionBuilder defaultSessionOpenOptions; private final transient SessionBuilder temporarySessionOpenOptions; - public SessionFactoryImpl( + public SessionFactoryImpl(final MetadataImplementor metadata, SessionFactoryOptions options) { + this( metadata, options, QueryPlanCache::new ); + } + + protected SessionFactoryImpl( final MetadataImplementor metadata, - SessionFactoryOptions options) { + SessionFactoryOptions options, Function queryPlanCacheFunction) { LOG.debug( "Building session factory" ); this.sessionFactoryOptions = options; @@ -256,7 +261,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor { LOG.debugf( "Session factory constructed with filter configurations : %s", filters ); LOG.debugf( "Instantiating session factory with properties: %s", properties ); - this.queryPlanCache = new QueryPlanCache( this ); + this.queryPlanCache = queryPlanCacheFunction.apply( this ); class IntegratorObserver implements SessionFactoryObserver { private ArrayList integrators = new ArrayList<>();