HHH-14024 Allow the creation of a different QueryPlanCache

This commit is contained in:
Davide D'Alto 2020-05-14 10:32:40 +01:00
parent e709685e16
commit 38d9f3738c
1 changed files with 8 additions and 3 deletions

View File

@ -18,6 +18,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.function.Function;
import java.util.function.Supplier; import java.util.function.Supplier;
import javax.naming.Reference; import javax.naming.Reference;
import javax.naming.StringRefAddr; import javax.naming.StringRefAddr;
@ -195,9 +196,13 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
private final transient SessionBuilder defaultSessionOpenOptions; private final transient SessionBuilder defaultSessionOpenOptions;
private final transient SessionBuilder temporarySessionOpenOptions; private final transient SessionBuilder temporarySessionOpenOptions;
public SessionFactoryImpl( public SessionFactoryImpl(final MetadataImplementor metadata, SessionFactoryOptions options) {
this( metadata, options, QueryPlanCache::new );
}
protected SessionFactoryImpl(
final MetadataImplementor metadata, final MetadataImplementor metadata,
SessionFactoryOptions options) { SessionFactoryOptions options, Function<SessionFactoryImplementor, QueryPlanCache> queryPlanCacheFunction) {
LOG.debug( "Building session factory" ); LOG.debug( "Building session factory" );
this.sessionFactoryOptions = options; this.sessionFactoryOptions = options;
@ -256,7 +261,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
LOG.debugf( "Session factory constructed with filter configurations : %s", filters ); LOG.debugf( "Session factory constructed with filter configurations : %s", filters );
LOG.debugf( "Instantiating session factory with properties: %s", properties ); LOG.debugf( "Instantiating session factory with properties: %s", properties );
this.queryPlanCache = new QueryPlanCache( this ); this.queryPlanCache = queryPlanCacheFunction.apply( this );
class IntegratorObserver implements SessionFactoryObserver { class IntegratorObserver implements SessionFactoryObserver {
private ArrayList<Integrator> integrators = new ArrayList<>(); private ArrayList<Integrator> integrators = new ArrayList<>();