HHH-12508 : SessionFactoryOptions#isSecondLevelCacheEnabled returns true by default with NoCachingRegionFactory

This commit is contained in:
Gail Badner 2018-04-25 12:18:28 -07:00
parent c2d98d78ea
commit 75c2a6d619
1 changed files with 37 additions and 19 deletions

View File

@ -37,6 +37,7 @@ import org.hibernate.boot.registry.selector.spi.StrategySelector;
import org.hibernate.boot.spi.MetadataImplementor; import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.boot.spi.SessionFactoryBuilderImplementor; import org.hibernate.boot.spi.SessionFactoryBuilderImplementor;
import org.hibernate.boot.spi.SessionFactoryOptions; import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.internal.NoCachingRegionFactory;
import org.hibernate.cache.internal.StandardQueryCacheFactory; import org.hibernate.cache.internal.StandardQueryCacheFactory;
import org.hibernate.cache.spi.QueryCacheFactory; import org.hibernate.cache.spi.QueryCacheFactory;
import org.hibernate.cache.spi.RegionFactory; import org.hibernate.cache.spi.RegionFactory;
@ -684,25 +685,42 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement
this.procedureParameterNullPassingEnabled = cfgService.getSetting( PROCEDURE_NULL_PARAM_PASSING, BOOLEAN, false ); this.procedureParameterNullPassingEnabled = cfgService.getSetting( PROCEDURE_NULL_PARAM_PASSING, BOOLEAN, false );
this.collectionJoinSubqueryRewriteEnabled = cfgService.getSetting( COLLECTION_JOIN_SUBQUERY, BOOLEAN, true ); this.collectionJoinSubqueryRewriteEnabled = cfgService.getSetting( COLLECTION_JOIN_SUBQUERY, BOOLEAN, true );
this.secondLevelCacheEnabled = cfgService.getSetting( USE_SECOND_LEVEL_CACHE, BOOLEAN, true ); final RegionFactory regionFactory = serviceRegistry.getService( RegionFactory.class );
this.queryCacheEnabled = cfgService.getSetting( USE_QUERY_CACHE, BOOLEAN, false ); if ( !NoCachingRegionFactory.class.isInstance( regionFactory ) ) {
this.queryCacheFactory = strategySelector.resolveDefaultableStrategy( this.secondLevelCacheEnabled = cfgService.getSetting( USE_SECOND_LEVEL_CACHE, BOOLEAN, true );
QueryCacheFactory.class, this.queryCacheEnabled = cfgService.getSetting( USE_QUERY_CACHE, BOOLEAN, false );
configurationSettings.get( QUERY_CACHE_FACTORY ), this.queryCacheFactory = strategySelector.resolveDefaultableStrategy(
StandardQueryCacheFactory.INSTANCE QueryCacheFactory.class,
); configurationSettings.get( QUERY_CACHE_FACTORY ),
this.cacheRegionPrefix = ConfigurationHelper.extractPropertyValue( StandardQueryCacheFactory.INSTANCE
CACHE_REGION_PREFIX, );
configurationSettings this.cacheRegionPrefix = ConfigurationHelper.extractPropertyValue(
); CACHE_REGION_PREFIX,
this.minimalPutsEnabled = cfgService.getSetting( configurationSettings
USE_MINIMAL_PUTS, );
BOOLEAN, this.minimalPutsEnabled = cfgService.getSetting(
serviceRegistry.getService( RegionFactory.class ).isMinimalPutsEnabledByDefault() USE_MINIMAL_PUTS,
); BOOLEAN,
this.structuredCacheEntriesEnabled = cfgService.getSetting( USE_STRUCTURED_CACHE, BOOLEAN, false ); regionFactory.isMinimalPutsEnabledByDefault()
this.directReferenceCacheEntriesEnabled = cfgService.getSetting( USE_DIRECT_REFERENCE_CACHE_ENTRIES,BOOLEAN, false ); );
this.autoEvictCollectionCache = cfgService.getSetting( AUTO_EVICT_COLLECTION_CACHE, BOOLEAN, false ); this.structuredCacheEntriesEnabled = cfgService.getSetting( USE_STRUCTURED_CACHE, BOOLEAN, false );
this.directReferenceCacheEntriesEnabled = cfgService.getSetting(
USE_DIRECT_REFERENCE_CACHE_ENTRIES,
BOOLEAN,
false
);
this.autoEvictCollectionCache = cfgService.getSetting( AUTO_EVICT_COLLECTION_CACHE, BOOLEAN, false );
}
else {
this.secondLevelCacheEnabled = false;
this.queryCacheEnabled = false;
this.queryCacheFactory = null;
this.cacheRegionPrefix = null;
this.minimalPutsEnabled = false;
this.structuredCacheEntriesEnabled = false;
this.directReferenceCacheEntriesEnabled = false;
this.autoEvictCollectionCache = false;
}
try { try {
this.schemaAutoTooling = SchemaAutoTooling.interpret( (String) configurationSettings.get( AvailableSettings.HBM2DDL_AUTO ) ); this.schemaAutoTooling = SchemaAutoTooling.interpret( (String) configurationSettings.get( AvailableSettings.HBM2DDL_AUTO ) );