diff --git a/hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryBuilderImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryBuilderImpl.java index 1aa2b7d7a8..edab8785b4 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryBuilderImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryBuilderImpl.java @@ -121,236 +121,11 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement private static final Logger log = Logger.getLogger( SessionFactoryBuilderImpl.class ); private final MetadataImplementor metadata; - private final StandardServiceRegistry serviceRegistry; - - // integration - private Object beanManagerReference; - private Object validatorFactoryReference; - - // SessionFactory behavior - private String sessionFactoryName; - private boolean sessionFactoryNameAlsoJndiName; - - // Session behavior - private boolean flushBeforeCompletionEnabled; - private boolean autoCloseSessionEnabled; - - // Statistics/Interceptor/observers - private boolean statisticsEnabled; - private Interceptor interceptor; - private List sessionFactoryObserverList = new ArrayList(); - private BaselineSessionEventsListenerBuilder baselineSessionEventsListenerBuilder; // not exposed on builder atm - - // persistence behavior - private CustomEntityDirtinessStrategy customEntityDirtinessStrategy; - private List entityNameResolvers = new ArrayList(); - private EntityNotFoundDelegate entityNotFoundDelegate; - private boolean identifierRollbackEnabled; - private EntityMode defaultEntityMode; - private EntityTuplizerFactory entityTuplizerFactory = new EntityTuplizerFactory(); - private boolean checkNullability; - private boolean initializeLazyStateOutsideTransactions; - private MultiTableBulkIdStrategy multiTableBulkIdStrategy; - private BatchFetchStyle batchFetchStyle; - private int defaultBatchFetchSize; - private Integer maximumFetchDepth; - private NullPrecedence defaultNullPrecedence; - private boolean orderUpdatesEnabled; - private boolean orderInsertsEnabled; - - // multi-tenancy - private MultiTenancyStrategy multiTenancyStrategy; - private CurrentTenantIdentifierResolver currentTenantIdentifierResolver; - - // JTA timeout detection - private boolean jtaTrackByThread; - - // Queries - private Map querySubstitutions; - private boolean strictJpaQueryLanguageCompliance; - private boolean namedQueryStartupCheckingEnabled; - - // Caching - private boolean secondLevelCacheEnabled; - private boolean queryCacheEnabled; - private QueryCacheFactory queryCacheFactory; - private String cacheRegionPrefix; - private boolean minimalPutsEnabled; - private boolean structuredCacheEntriesEnabled; - private boolean directReferenceCacheEntriesEnabled; - private boolean autoEvictCollectionCache; - - // Schema tooling - private SchemaAutoTooling schemaAutoTooling; - - // JDBC Handling - private boolean dataDefinitionImplicitCommit; // not exposed on builder atm - private boolean dataDefinitionInTransactionSupported; // not exposed on builder atm - private boolean getGeneratedKeysEnabled; - private int jdbcBatchSize; - private boolean jdbcBatchVersionedData; - private Integer jdbcFetchSize; - private boolean scrollableResultSetsEnabled; - private boolean commentsEnabled; - private ConnectionReleaseMode connectionReleaseMode; - private boolean wrapResultSetsEnabled; - - private Map sqlFunctions; + private final SessionFactoryOptionsStateStandardImpl options; SessionFactoryBuilderImpl(MetadataImplementor metadata) { this.metadata = metadata; - this.serviceRegistry = metadata.getMetadataBuildingOptions().getServiceRegistry(); - - initializeState(); - } - - private void initializeState() { - final StrategySelector strategySelector = serviceRegistry.getService( StrategySelector.class ); - ConfigurationService cfgService = serviceRegistry.getService( ConfigurationService.class ); - final JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class ); - - final Map configurationSettings = new HashMap(); - //noinspection unchecked - configurationSettings.putAll( cfgService.getSettings() ); - //noinspection unchecked - configurationSettings.putAll( jdbcServices.getJdbcEnvironment().getDialect().getDefaultProperties() ); - cfgService = new ConfigurationServiceImpl( configurationSettings ); - ( (ConfigurationServiceImpl) cfgService ).injectServices( (ServiceRegistryImplementor) serviceRegistry ); - - this.beanManagerReference = configurationSettings.get( "javax.persistence.bean.manager" ); - this.validatorFactoryReference = configurationSettings.get( "javax.persistence.validation.factory" ); - - this.sessionFactoryName = (String) configurationSettings.get( SESSION_FACTORY_NAME ); - this.sessionFactoryNameAlsoJndiName = cfgService.getSetting( - SESSION_FACTORY_NAME_IS_JNDI, - BOOLEAN, - true - ); - - this.flushBeforeCompletionEnabled = cfgService.getSetting( FLUSH_BEFORE_COMPLETION, BOOLEAN, false ); - this.autoCloseSessionEnabled = cfgService.getSetting( AUTO_CLOSE_SESSION, BOOLEAN, false ); - - this.statisticsEnabled = cfgService.getSetting( GENERATE_STATISTICS, BOOLEAN, false ); - this.interceptor = strategySelector.resolveDefaultableStrategy( - Interceptor.class, - configurationSettings.get( INTERCEPTOR ), - EmptyInterceptor.INSTANCE - ); - // todo : expose this from builder? - final String autoSessionEventsListenerName = (String) configurationSettings.get( - AUTO_SESSION_EVENTS_LISTENER - ); - final Class autoSessionEventsListener = autoSessionEventsListenerName == null - ? null - : strategySelector.selectStrategyImplementor( SessionEventListener.class, autoSessionEventsListenerName ); - - final boolean logSessionMetrics = cfgService.getSetting( LOG_SESSION_METRICS, BOOLEAN, statisticsEnabled ); - this.baselineSessionEventsListenerBuilder = new BaselineSessionEventsListenerBuilder( logSessionMetrics, autoSessionEventsListener ); - - this.customEntityDirtinessStrategy = strategySelector.resolveDefaultableStrategy( - CustomEntityDirtinessStrategy.class, - configurationSettings.get( CUSTOM_ENTITY_DIRTINESS_STRATEGY ), - DefaultCustomEntityDirtinessStrategy.INSTANCE - ); - - this.entityNotFoundDelegate = StandardEntityNotFoundDelegate.INSTANCE; - this.identifierRollbackEnabled = cfgService.getSetting( USE_IDENTIFIER_ROLLBACK, BOOLEAN, false ); - this.defaultEntityMode = EntityMode.parse( (String) configurationSettings.get( DEFAULT_ENTITY_MODE ) ); - this.checkNullability = cfgService.getSetting( CHECK_NULLABILITY, BOOLEAN, true ); - this.initializeLazyStateOutsideTransactions = cfgService.getSetting( ENABLE_LAZY_LOAD_NO_TRANS, BOOLEAN, false ); - - this.multiTenancyStrategy = MultiTenancyStrategy.determineMultiTenancyStrategy( configurationSettings ); - this.currentTenantIdentifierResolver = strategySelector.resolveStrategy( - CurrentTenantIdentifierResolver.class, - configurationSettings.get( MULTI_TENANT_IDENTIFIER_RESOLVER ) - ); - - this.multiTableBulkIdStrategy = strategySelector.resolveDefaultableStrategy( - MultiTableBulkIdStrategy.class, - configurationSettings.get( HQL_BULK_ID_STRATEGY ), - jdbcServices.getJdbcEnvironment().getDialect().getDefaultMultiTableBulkIdStrategy() - ); - - this.batchFetchStyle = BatchFetchStyle.interpret( configurationSettings.get( BATCH_FETCH_STYLE ) ); - this.defaultBatchFetchSize = ConfigurationHelper.getInt( DEFAULT_BATCH_FETCH_SIZE, configurationSettings, -1 ); - this.maximumFetchDepth = ConfigurationHelper.getInteger( MAX_FETCH_DEPTH, configurationSettings ); - final String defaultNullPrecedence = ConfigurationHelper.getString( - AvailableSettings.DEFAULT_NULL_ORDERING, configurationSettings, "none", "first", "last" - ); - this.defaultNullPrecedence = NullPrecedence.parse( defaultNullPrecedence ); - this.orderUpdatesEnabled = ConfigurationHelper.getBoolean( ORDER_UPDATES, configurationSettings ); - this.orderInsertsEnabled = ConfigurationHelper.getBoolean( ORDER_INSERTS, configurationSettings ); - - this.jtaTrackByThread = cfgService.getSetting( JTA_TRACK_BY_THREAD, BOOLEAN, true ); - - this.querySubstitutions = ConfigurationHelper.toMap( QUERY_SUBSTITUTIONS, " ,=;:\n\t\r\f", configurationSettings ); - this.strictJpaQueryLanguageCompliance = cfgService.getSetting( JPAQL_STRICT_COMPLIANCE, BOOLEAN, false ); - this.namedQueryStartupCheckingEnabled = cfgService.getSetting( QUERY_STARTUP_CHECKING, BOOLEAN, true ); - - this.secondLevelCacheEnabled = cfgService.getSetting( USE_SECOND_LEVEL_CACHE, BOOLEAN, true ); - this.queryCacheEnabled = cfgService.getSetting( USE_QUERY_CACHE, BOOLEAN, false ); - this.queryCacheFactory = strategySelector.resolveDefaultableStrategy( - QueryCacheFactory.class, - configurationSettings.get( QUERY_CACHE_FACTORY ), - StandardQueryCacheFactory.INSTANCE - ); - this.cacheRegionPrefix = ConfigurationHelper.extractPropertyValue( - CACHE_REGION_PREFIX, - configurationSettings - ); - this.minimalPutsEnabled = cfgService.getSetting( - USE_MINIMAL_PUTS, - BOOLEAN, - serviceRegistry.getService( RegionFactory.class ).isMinimalPutsEnabledByDefault() - ); - 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 ); - - try { - this.schemaAutoTooling = SchemaAutoTooling.interpret( (String) configurationSettings.get( AvailableSettings.HBM2DDL_AUTO ) ); - } - catch (Exception e) { - log.warn( e.getMessage() + " Ignoring" ); - } - - - final ExtractedDatabaseMetaData meta = jdbcServices.getExtractedMetaDataSupport(); - this.dataDefinitionImplicitCommit = meta.doesDataDefinitionCauseTransactionCommit(); - this.dataDefinitionInTransactionSupported = meta.supportsDataDefinitionInTransaction(); - - this.jdbcBatchSize = ConfigurationHelper.getInt( STATEMENT_BATCH_SIZE, configurationSettings, 0 ); - if ( !meta.supportsBatchUpdates() ) { - this.jdbcBatchSize = 0; - } - - this.jdbcBatchVersionedData = ConfigurationHelper.getBoolean( BATCH_VERSIONED_DATA, configurationSettings, false ); - this.scrollableResultSetsEnabled = ConfigurationHelper.getBoolean( - USE_SCROLLABLE_RESULTSET, - configurationSettings, - meta.supportsScrollableResults() - ); - this.wrapResultSetsEnabled = ConfigurationHelper.getBoolean( - WRAP_RESULT_SETS, - configurationSettings, - false - ); - this.getGeneratedKeysEnabled = ConfigurationHelper.getBoolean( - USE_GET_GENERATED_KEYS, - configurationSettings, - meta.supportsGetGeneratedKeys() - ); - this.jdbcFetchSize = ConfigurationHelper.getInteger( STATEMENT_FETCH_SIZE, configurationSettings ); - - final String releaseModeName = ConfigurationHelper.getString( RELEASE_CONNECTIONS, configurationSettings, "auto" ); - if ( "auto".equals( releaseModeName ) ) { - this.connectionReleaseMode = serviceRegistry.getService( TransactionFactory.class ).getDefaultReleaseMode(); - } - else { - connectionReleaseMode = ConnectionReleaseMode.parse( releaseModeName ); - } - - this.commentsEnabled = ConfigurationHelper.getBoolean( USE_SQL_COMMENTS, configurationSettings ); + this.options = new SessionFactoryOptionsStateStandardImpl( metadata.getMetadataBuildingOptions().getServiceRegistry() ); if ( metadata.getSqlFunctionMap() != null ) { for ( Map.Entry sqlFunctionEntry : metadata.getSqlFunctionMap().entrySet() ) { @@ -361,104 +136,104 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement @Override public SessionFactoryBuilder applyValidatorFactory(Object validatorFactory) { - this.validatorFactoryReference = validatorFactory; + this.options.validatorFactoryReference = validatorFactory; return this; } @Override public SessionFactoryBuilder applyBeanManager(Object beanManager) { - this.beanManagerReference = beanManager; + this.options.beanManagerReference = beanManager; return this; } @Override public SessionFactoryBuilder applyName(String sessionFactoryName) { - this.sessionFactoryName = sessionFactoryName; + this.options.sessionFactoryName = sessionFactoryName; return this; } @Override public SessionFactoryBuilder applyNameAsJndiName(boolean isJndiName) { - this.sessionFactoryNameAlsoJndiName = isJndiName; + this.options.sessionFactoryNameAlsoJndiName = isJndiName; return this; } @Override public SessionFactoryBuilder applyAutoClosing(boolean enabled) { - this.autoCloseSessionEnabled = enabled; + this.options.autoCloseSessionEnabled = enabled; return this; } @Override public SessionFactoryBuilder applyAutoFlushing(boolean enabled) { - this.flushBeforeCompletionEnabled = enabled; + this.options.flushBeforeCompletionEnabled = enabled; return this; } @Override public SessionFactoryBuilder applyStatisticsSupport(boolean enabled) { - this.statisticsEnabled = enabled; + this.options.statisticsEnabled = enabled; return this; } @Override public SessionFactoryBuilder addSessionFactoryObservers(SessionFactoryObserver... observers) { - this.sessionFactoryObserverList.addAll( Arrays.asList( observers ) ); + this.options.sessionFactoryObserverList.addAll( Arrays.asList( observers ) ); return this; } @Override public SessionFactoryBuilder applyInterceptor(Interceptor interceptor) { - this.interceptor = interceptor; + this.options.interceptor = interceptor; return this; } @Override public SessionFactoryBuilder applyCustomEntityDirtinessStrategy(CustomEntityDirtinessStrategy strategy) { - this.customEntityDirtinessStrategy = strategy; + this.options.customEntityDirtinessStrategy = strategy; return this; } @Override public SessionFactoryBuilder addEntityNameResolver(EntityNameResolver... entityNameResolvers) { - this.entityNameResolvers.addAll( Arrays.asList( entityNameResolvers ) ); + this.options.entityNameResolvers.addAll( Arrays.asList( entityNameResolvers ) ); return this; } @Override public SessionFactoryBuilder applyEntityNotFoundDelegate(EntityNotFoundDelegate entityNotFoundDelegate) { - this.entityNotFoundDelegate = entityNotFoundDelegate; + this.options.entityNotFoundDelegate = entityNotFoundDelegate; return this; } @Override public SessionFactoryBuilder applyIdentifierRollbackSupport(boolean enabled) { - this.identifierRollbackEnabled = enabled; + this.options.identifierRollbackEnabled = enabled; return this; } @Override public SessionFactoryBuilder applyDefaultEntityMode(EntityMode entityMode) { - this.defaultEntityMode = entityMode; + this.options.defaultEntityMode = entityMode; return this; } @Override public SessionFactoryBuilder applyNullabilityChecking(boolean enabled) { - this.checkNullability = enabled; + this.options.checkNullability = enabled; return this; } @Override public SessionFactoryBuilder applyLazyInitializationOutsideTransaction(boolean enabled) { - this.initializeLazyStateOutsideTransactions = enabled; + this.options.initializeLazyStateOutsideTransactions = enabled; return this; } @Override public SessionFactoryBuilder applyEntityTuplizerFactory(EntityTuplizerFactory entityTuplizerFactory) { - this.entityTuplizerFactory = entityTuplizerFactory; + this.options.entityTuplizerFactory = entityTuplizerFactory; return this; } @@ -466,191 +241,191 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement public SessionFactoryBuilder applyEntityTuplizer( EntityMode entityMode, Class tuplizerClass) { - this.entityTuplizerFactory.registerDefaultTuplizerClass( entityMode, tuplizerClass ); + this.options.entityTuplizerFactory.registerDefaultTuplizerClass( entityMode, tuplizerClass ); return this; } @Override public SessionFactoryBuilder applyMultiTableBulkIdStrategy(MultiTableBulkIdStrategy strategy) { - this.multiTableBulkIdStrategy = strategy; + this.options.multiTableBulkIdStrategy = strategy; return this; } @Override public SessionFactoryBuilder applyBatchFetchStyle(BatchFetchStyle style) { - this.batchFetchStyle = style; + this.options.batchFetchStyle = style; return this; } @Override public SessionFactoryBuilder applyDefaultBatchFetchSize(int size) { - this.defaultBatchFetchSize = size; + this.options.defaultBatchFetchSize = size; return this; } @Override public SessionFactoryBuilder applyMaximumFetchDepth(int depth) { - this.maximumFetchDepth = depth; + this.options.maximumFetchDepth = depth; return this; } @Override public SessionFactoryBuilder applyDefaultNullPrecedence(NullPrecedence nullPrecedence) { - this.defaultNullPrecedence = nullPrecedence; + this.options.defaultNullPrecedence = nullPrecedence; return this; } @Override public SessionFactoryBuilder applyOrderingOfInserts(boolean enabled) { - this.orderInsertsEnabled = enabled; + this.options.orderInsertsEnabled = enabled; return this; } @Override public SessionFactoryBuilder applyOrderingOfUpdates(boolean enabled) { - this.orderUpdatesEnabled = enabled; + this.options.orderUpdatesEnabled = enabled; return this; } @Override public SessionFactoryBuilder applyMultiTenancyStrategy(MultiTenancyStrategy strategy) { - this.multiTenancyStrategy = strategy; + this.options.multiTenancyStrategy = strategy; return this; } @Override public SessionFactoryBuilder applyCurrentTenantIdentifierResolver(CurrentTenantIdentifierResolver resolver) { - this.currentTenantIdentifierResolver = resolver; + this.options.currentTenantIdentifierResolver = resolver; return this; } @Override public SessionFactoryBuilder applyJtaTrackingByThread(boolean enabled) { - this.jtaTrackByThread = enabled; + this.options.jtaTrackByThread = enabled; return this; } @Override @SuppressWarnings("unchecked") public SessionFactoryBuilder applyQuerySubstitutions(Map substitutions) { - this.querySubstitutions.putAll( substitutions ); + this.options.querySubstitutions.putAll( substitutions ); return this; } @Override public SessionFactoryBuilder applyStrictJpaQueryLanguageCompliance(boolean enabled) { - this.strictJpaQueryLanguageCompliance = enabled; + this.options.strictJpaQueryLanguageCompliance = enabled; return this; } @Override public SessionFactoryBuilder applyNamedQueryCheckingOnStartup(boolean enabled) { - this.namedQueryStartupCheckingEnabled = enabled; + this.options.namedQueryStartupCheckingEnabled = enabled; return this; } @Override public SessionFactoryBuilder applySecondLevelCacheSupport(boolean enabled) { - this.secondLevelCacheEnabled = enabled; + this.options.secondLevelCacheEnabled = enabled; return this; } @Override public SessionFactoryBuilder applyQueryCacheSupport(boolean enabled) { - this.queryCacheEnabled = enabled; + this.options.queryCacheEnabled = enabled; return this; } @Override public SessionFactoryBuilder applyQueryCacheFactory(QueryCacheFactory factory) { - this.queryCacheFactory = factory; + this.options.queryCacheFactory = factory; return this; } @Override public SessionFactoryBuilder applyCacheRegionPrefix(String prefix) { - this.cacheRegionPrefix = prefix; + this.options.cacheRegionPrefix = prefix; return this; } @Override public SessionFactoryBuilder applyMinimalPutsForCaching(boolean enabled) { - this.minimalPutsEnabled = enabled; + this.options.minimalPutsEnabled = enabled; return this; } @Override public SessionFactoryBuilder applyStructuredCacheEntries(boolean enabled) { - this.structuredCacheEntriesEnabled = enabled; + this.options.structuredCacheEntriesEnabled = enabled; return this; } @Override public SessionFactoryBuilder applyDirectReferenceCaching(boolean enabled) { - this.directReferenceCacheEntriesEnabled = enabled; + this.options.directReferenceCacheEntriesEnabled = enabled; return this; } @Override public SessionFactoryBuilder applyAutomaticEvictionOfCollectionCaches(boolean enabled) { - this.autoEvictCollectionCache = enabled; + this.options.autoEvictCollectionCache = enabled; return this; } @Override public SessionFactoryBuilder applyJdbcBatchSize(int size) { - this.jdbcBatchSize = size; + this.options.jdbcBatchSize = size; return this; } @Override public SessionFactoryBuilder applyJdbcBatchingForVersionedEntities(boolean enabled) { - this.jdbcBatchVersionedData = enabled; + this.options.jdbcBatchVersionedData = enabled; return this; } @Override public SessionFactoryBuilder applyScrollableResultsSupport(boolean enabled) { - this.scrollableResultSetsEnabled = enabled; + this.options.scrollableResultSetsEnabled = enabled; return this; } @Override public SessionFactoryBuilder applyResultSetsWrapping(boolean enabled) { - this.wrapResultSetsEnabled = enabled; + this.options.wrapResultSetsEnabled = enabled; return this; } @Override public SessionFactoryBuilder applyGetGeneratedKeysSupport(boolean enabled) { - this.getGeneratedKeysEnabled = enabled; + this.options.getGeneratedKeysEnabled = enabled; return this; } @Override public SessionFactoryBuilder applyJdbcFetchSize(int size) { - this.jdbcFetchSize = size; + this.options.jdbcFetchSize = size; return this; } @Override public SessionFactoryBuilder applyConnectionReleaseMode(ConnectionReleaseMode connectionReleaseMode) { - this.connectionReleaseMode = connectionReleaseMode; + this.options.connectionReleaseMode = connectionReleaseMode; return this; } @Override public SessionFactoryBuilder applySqlComments(boolean enabled) { - this.commentsEnabled = enabled; + this.options.commentsEnabled = enabled; return this; } @Override public SessionFactoryBuilder applySqlFunction(String registrationName, SQLFunction sqlFunction) { - if ( this.sqlFunctions == null ) { - this.sqlFunctions = new HashMap(); + if ( this.options.sqlFunctions == null ) { + this.options.sqlFunctions = new HashMap(); } - this.sqlFunctions.put( registrationName, sqlFunction ); + this.options.sqlFunctions.put( registrationName, sqlFunction ); return this; } @@ -675,263 +450,753 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement // SessionFactoryOptionsState impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + public static class SessionFactoryOptionsStateStandardImpl implements SessionFactoryOptionsState { + private final StandardServiceRegistry serviceRegistry; + + // integration + private Object beanManagerReference; + private Object validatorFactoryReference; + + // SessionFactory behavior + private String sessionFactoryName; + private boolean sessionFactoryNameAlsoJndiName; + + // Session behavior + private boolean flushBeforeCompletionEnabled; + private boolean autoCloseSessionEnabled; + + // Statistics/Interceptor/observers + private boolean statisticsEnabled; + private Interceptor interceptor; + private List sessionFactoryObserverList = new ArrayList(); + private BaselineSessionEventsListenerBuilder baselineSessionEventsListenerBuilder; // not exposed on builder atm + + // persistence behavior + private CustomEntityDirtinessStrategy customEntityDirtinessStrategy; + private List entityNameResolvers = new ArrayList(); + private EntityNotFoundDelegate entityNotFoundDelegate; + private boolean identifierRollbackEnabled; + private EntityMode defaultEntityMode; + private EntityTuplizerFactory entityTuplizerFactory = new EntityTuplizerFactory(); + private boolean checkNullability; + private boolean initializeLazyStateOutsideTransactions; + private MultiTableBulkIdStrategy multiTableBulkIdStrategy; + private BatchFetchStyle batchFetchStyle; + private int defaultBatchFetchSize; + private Integer maximumFetchDepth; + private NullPrecedence defaultNullPrecedence; + private boolean orderUpdatesEnabled; + private boolean orderInsertsEnabled; + + // multi-tenancy + private MultiTenancyStrategy multiTenancyStrategy; + private CurrentTenantIdentifierResolver currentTenantIdentifierResolver; + + // JTA timeout detection + private boolean jtaTrackByThread; + + // Queries + private Map querySubstitutions; + private boolean strictJpaQueryLanguageCompliance; + private boolean namedQueryStartupCheckingEnabled; + + // Caching + private boolean secondLevelCacheEnabled; + private boolean queryCacheEnabled; + private QueryCacheFactory queryCacheFactory; + private String cacheRegionPrefix; + private boolean minimalPutsEnabled; + private boolean structuredCacheEntriesEnabled; + private boolean directReferenceCacheEntriesEnabled; + private boolean autoEvictCollectionCache; + + // Schema tooling + private SchemaAutoTooling schemaAutoTooling; + + // JDBC Handling + private boolean dataDefinitionImplicitCommit; // not exposed on builder atm + private boolean dataDefinitionInTransactionSupported; // not exposed on builder atm + private boolean getGeneratedKeysEnabled; + private int jdbcBatchSize; + private boolean jdbcBatchVersionedData; + private Integer jdbcFetchSize; + private boolean scrollableResultSetsEnabled; + private boolean commentsEnabled; + private ConnectionReleaseMode connectionReleaseMode; + private boolean wrapResultSetsEnabled; + + private Map sqlFunctions; + + public SessionFactoryOptionsStateStandardImpl(StandardServiceRegistry serviceRegistry) { + this.serviceRegistry = serviceRegistry; + + final StrategySelector strategySelector = serviceRegistry.getService( StrategySelector.class ); + ConfigurationService cfgService = serviceRegistry.getService( ConfigurationService.class ); + final JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class ); + + final Map configurationSettings = new HashMap(); + //noinspection unchecked + configurationSettings.putAll( cfgService.getSettings() ); + //noinspection unchecked + configurationSettings.putAll( jdbcServices.getJdbcEnvironment().getDialect().getDefaultProperties() ); + cfgService = new ConfigurationServiceImpl( configurationSettings ); + ( (ConfigurationServiceImpl) cfgService ).injectServices( (ServiceRegistryImplementor) serviceRegistry ); + + this.beanManagerReference = configurationSettings.get( "javax.persistence.bean.manager" ); + this.validatorFactoryReference = configurationSettings.get( "javax.persistence.validation.factory" ); + + this.sessionFactoryName = (String) configurationSettings.get( SESSION_FACTORY_NAME ); + this.sessionFactoryNameAlsoJndiName = cfgService.getSetting( + SESSION_FACTORY_NAME_IS_JNDI, + BOOLEAN, + true + ); + + this.flushBeforeCompletionEnabled = cfgService.getSetting( FLUSH_BEFORE_COMPLETION, BOOLEAN, false ); + this.autoCloseSessionEnabled = cfgService.getSetting( AUTO_CLOSE_SESSION, BOOLEAN, false ); + + this.statisticsEnabled = cfgService.getSetting( GENERATE_STATISTICS, BOOLEAN, false ); + this.interceptor = strategySelector.resolveDefaultableStrategy( + Interceptor.class, + configurationSettings.get( INTERCEPTOR ), + EmptyInterceptor.INSTANCE + ); + // todo : expose this from builder? + final String autoSessionEventsListenerName = (String) configurationSettings.get( + AUTO_SESSION_EVENTS_LISTENER + ); + final Class autoSessionEventsListener = autoSessionEventsListenerName == null + ? null + : strategySelector.selectStrategyImplementor( SessionEventListener.class, autoSessionEventsListenerName ); + + final boolean logSessionMetrics = cfgService.getSetting( LOG_SESSION_METRICS, BOOLEAN, statisticsEnabled ); + this.baselineSessionEventsListenerBuilder = new BaselineSessionEventsListenerBuilder( logSessionMetrics, autoSessionEventsListener ); + + this.customEntityDirtinessStrategy = strategySelector.resolveDefaultableStrategy( + CustomEntityDirtinessStrategy.class, + configurationSettings.get( CUSTOM_ENTITY_DIRTINESS_STRATEGY ), + DefaultCustomEntityDirtinessStrategy.INSTANCE + ); + + this.entityNotFoundDelegate = StandardEntityNotFoundDelegate.INSTANCE; + this.identifierRollbackEnabled = cfgService.getSetting( USE_IDENTIFIER_ROLLBACK, BOOLEAN, false ); + this.defaultEntityMode = EntityMode.parse( (String) configurationSettings.get( DEFAULT_ENTITY_MODE ) ); + this.checkNullability = cfgService.getSetting( CHECK_NULLABILITY, BOOLEAN, true ); + this.initializeLazyStateOutsideTransactions = cfgService.getSetting( ENABLE_LAZY_LOAD_NO_TRANS, BOOLEAN, false ); + + this.multiTenancyStrategy = MultiTenancyStrategy.determineMultiTenancyStrategy( configurationSettings ); + this.currentTenantIdentifierResolver = strategySelector.resolveStrategy( + CurrentTenantIdentifierResolver.class, + configurationSettings.get( MULTI_TENANT_IDENTIFIER_RESOLVER ) + ); + + this.multiTableBulkIdStrategy = strategySelector.resolveDefaultableStrategy( + MultiTableBulkIdStrategy.class, + configurationSettings.get( HQL_BULK_ID_STRATEGY ), + jdbcServices.getJdbcEnvironment().getDialect().getDefaultMultiTableBulkIdStrategy() + ); + + this.batchFetchStyle = BatchFetchStyle.interpret( configurationSettings.get( BATCH_FETCH_STYLE ) ); + this.defaultBatchFetchSize = ConfigurationHelper.getInt( DEFAULT_BATCH_FETCH_SIZE, configurationSettings, -1 ); + this.maximumFetchDepth = ConfigurationHelper.getInteger( MAX_FETCH_DEPTH, configurationSettings ); + final String defaultNullPrecedence = ConfigurationHelper.getString( + AvailableSettings.DEFAULT_NULL_ORDERING, configurationSettings, "none", "first", "last" + ); + this.defaultNullPrecedence = NullPrecedence.parse( defaultNullPrecedence ); + this.orderUpdatesEnabled = ConfigurationHelper.getBoolean( ORDER_UPDATES, configurationSettings ); + this.orderInsertsEnabled = ConfigurationHelper.getBoolean( ORDER_INSERTS, configurationSettings ); + + this.jtaTrackByThread = cfgService.getSetting( JTA_TRACK_BY_THREAD, BOOLEAN, true ); + + this.querySubstitutions = ConfigurationHelper.toMap( QUERY_SUBSTITUTIONS, " ,=;:\n\t\r\f", configurationSettings ); + this.strictJpaQueryLanguageCompliance = cfgService.getSetting( JPAQL_STRICT_COMPLIANCE, BOOLEAN, false ); + this.namedQueryStartupCheckingEnabled = cfgService.getSetting( QUERY_STARTUP_CHECKING, BOOLEAN, true ); + + this.secondLevelCacheEnabled = cfgService.getSetting( USE_SECOND_LEVEL_CACHE, BOOLEAN, true ); + this.queryCacheEnabled = cfgService.getSetting( USE_QUERY_CACHE, BOOLEAN, false ); + this.queryCacheFactory = strategySelector.resolveDefaultableStrategy( + QueryCacheFactory.class, + configurationSettings.get( QUERY_CACHE_FACTORY ), + StandardQueryCacheFactory.INSTANCE + ); + this.cacheRegionPrefix = ConfigurationHelper.extractPropertyValue( + CACHE_REGION_PREFIX, + configurationSettings + ); + this.minimalPutsEnabled = cfgService.getSetting( + USE_MINIMAL_PUTS, + BOOLEAN, + serviceRegistry.getService( RegionFactory.class ).isMinimalPutsEnabledByDefault() + ); + 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 ); + + try { + this.schemaAutoTooling = SchemaAutoTooling.interpret( (String) configurationSettings.get( AvailableSettings.HBM2DDL_AUTO ) ); + } + catch (Exception e) { + log.warn( e.getMessage() + " Ignoring" ); + } + + + final ExtractedDatabaseMetaData meta = jdbcServices.getExtractedMetaDataSupport(); + this.dataDefinitionImplicitCommit = meta.doesDataDefinitionCauseTransactionCommit(); + this.dataDefinitionInTransactionSupported = meta.supportsDataDefinitionInTransaction(); + + this.jdbcBatchSize = ConfigurationHelper.getInt( STATEMENT_BATCH_SIZE, configurationSettings, 0 ); + if ( !meta.supportsBatchUpdates() ) { + this.jdbcBatchSize = 0; + } + + this.jdbcBatchVersionedData = ConfigurationHelper.getBoolean( BATCH_VERSIONED_DATA, configurationSettings, false ); + this.scrollableResultSetsEnabled = ConfigurationHelper.getBoolean( + USE_SCROLLABLE_RESULTSET, + configurationSettings, + meta.supportsScrollableResults() + ); + this.wrapResultSetsEnabled = ConfigurationHelper.getBoolean( + WRAP_RESULT_SETS, + configurationSettings, + false + ); + this.getGeneratedKeysEnabled = ConfigurationHelper.getBoolean( + USE_GET_GENERATED_KEYS, + configurationSettings, + meta.supportsGetGeneratedKeys() + ); + this.jdbcFetchSize = ConfigurationHelper.getInteger( STATEMENT_FETCH_SIZE, configurationSettings ); + + final String releaseModeName = ConfigurationHelper.getString( RELEASE_CONNECTIONS, configurationSettings, "auto" ); + if ( "auto".equals( releaseModeName ) ) { + this.connectionReleaseMode = serviceRegistry.getService( TransactionFactory.class ).getDefaultReleaseMode(); + } + else { + connectionReleaseMode = ConnectionReleaseMode.parse( releaseModeName ); + } + + this.commentsEnabled = ConfigurationHelper.getBoolean( USE_SQL_COMMENTS, configurationSettings ); + } + + @Override + public StandardServiceRegistry getServiceRegistry() { + return serviceRegistry; + } + + @Override + public Object getBeanManagerReference() { + return beanManagerReference; + } + + @Override + public Object getValidatorFactoryReference() { + return validatorFactoryReference; + } + + @Override + public String getSessionFactoryName() { + return sessionFactoryName; + } + + @Override + public boolean isSessionFactoryNameAlsoJndiName() { + return sessionFactoryNameAlsoJndiName; + } + + @Override + public boolean isFlushBeforeCompletionEnabled() { + return flushBeforeCompletionEnabled; + } + + @Override + public boolean isAutoCloseSessionEnabled() { + return autoCloseSessionEnabled; + } + + @Override + public boolean isStatisticsEnabled() { + return statisticsEnabled; + } + + @Override + public Interceptor getInterceptor() { + return interceptor == null ? EmptyInterceptor.INSTANCE : interceptor; + } + + @Override + public SessionFactoryObserver[] getSessionFactoryObservers() { + return sessionFactoryObserverList.toArray( new SessionFactoryObserver[ sessionFactoryObserverList.size() ] ); + } + + @Override + public BaselineSessionEventsListenerBuilder getBaselineSessionEventsListenerBuilder() { + return baselineSessionEventsListenerBuilder; + } + + @Override + public boolean isIdentifierRollbackEnabled() { + return identifierRollbackEnabled; + } + + @Override + public EntityMode getDefaultEntityMode() { + return defaultEntityMode; + } + + @Override + public EntityTuplizerFactory getEntityTuplizerFactory() { + return entityTuplizerFactory; + } + + @Override + public boolean isCheckNullability() { + return checkNullability; + } + + @Override + public boolean isInitializeLazyStateOutsideTransactionsEnabled() { + return initializeLazyStateOutsideTransactions; + } + + @Override + public MultiTableBulkIdStrategy getMultiTableBulkIdStrategy() { + return multiTableBulkIdStrategy; + } + + @Override + public BatchFetchStyle getBatchFetchStyle() { + return batchFetchStyle; + } + + @Override + public int getDefaultBatchFetchSize() { + return defaultBatchFetchSize; + } + + @Override + public Integer getMaximumFetchDepth() { + return maximumFetchDepth; + } + + @Override + public NullPrecedence getDefaultNullPrecedence() { + return defaultNullPrecedence; + } + + @Override + public boolean isOrderUpdatesEnabled() { + return orderUpdatesEnabled; + } + + @Override + public boolean isOrderInsertsEnabled() { + return orderInsertsEnabled; + } + + @Override + public MultiTenancyStrategy getMultiTenancyStrategy() { + return multiTenancyStrategy; + } + + @Override + public CurrentTenantIdentifierResolver getCurrentTenantIdentifierResolver() { + return currentTenantIdentifierResolver; + } + + @Override + public boolean isJtaTrackByThread() { + return jtaTrackByThread; + } + + @Override + public Map getQuerySubstitutions() { + return querySubstitutions; + } + + @Override + public boolean isStrictJpaQueryLanguageCompliance() { + return strictJpaQueryLanguageCompliance; + } + + @Override + public boolean isNamedQueryStartupCheckingEnabled() { + return namedQueryStartupCheckingEnabled; + } + + @Override + public boolean isSecondLevelCacheEnabled() { + return secondLevelCacheEnabled; + } + + @Override + public boolean isQueryCacheEnabled() { + return queryCacheEnabled; + } + + @Override + public QueryCacheFactory getQueryCacheFactory() { + return queryCacheFactory; + } + + @Override + public String getCacheRegionPrefix() { + return cacheRegionPrefix; + } + + @Override + public boolean isMinimalPutsEnabled() { + return minimalPutsEnabled; + } + + @Override + public boolean isStructuredCacheEntriesEnabled() { + return structuredCacheEntriesEnabled; + } + + @Override + public boolean isDirectReferenceCacheEntriesEnabled() { + return directReferenceCacheEntriesEnabled; + } + + @Override + public boolean isAutoEvictCollectionCache() { + return autoEvictCollectionCache; + } + + @Override + public SchemaAutoTooling getSchemaAutoTooling() { + return schemaAutoTooling; + } + + @Override + public boolean isDataDefinitionImplicitCommit() { + return dataDefinitionImplicitCommit; + } + + @Override + public boolean isDataDefinitionInTransactionSupported() { + return dataDefinitionInTransactionSupported; + } + + @Override + public int getJdbcBatchSize() { + return jdbcBatchSize; + } + + @Override + public boolean isJdbcBatchVersionedData() { + return jdbcBatchVersionedData; + } + + @Override + public boolean isScrollableResultSetsEnabled() { + return scrollableResultSetsEnabled; + } + + @Override + public boolean isWrapResultSetsEnabled() { + return wrapResultSetsEnabled; + } + + @Override + public boolean isGetGeneratedKeysEnabled() { + return getGeneratedKeysEnabled; + } + + @Override + public Integer getJdbcFetchSize() { + return jdbcFetchSize; + } + + @Override + public ConnectionReleaseMode getConnectionReleaseMode() { + return connectionReleaseMode; + } + + @Override + public boolean isCommentsEnabled() { + return commentsEnabled; + } + + @Override + public CustomEntityDirtinessStrategy getCustomEntityDirtinessStrategy() { + return customEntityDirtinessStrategy; + } + + @Override + public EntityNameResolver[] getEntityNameResolvers() { + return entityNameResolvers.toArray( new EntityNameResolver[ entityNameResolvers.size() ] ); + } + + @Override + public EntityNotFoundDelegate getEntityNotFoundDelegate() { + return entityNotFoundDelegate; + } + + @Override + public Map getCustomSqlFunctionMap() { + return sqlFunctions == null ? Collections.emptyMap() : sqlFunctions; + } + + } + @Override public StandardServiceRegistry getServiceRegistry() { - return serviceRegistry; + return options.getServiceRegistry(); } @Override public Object getBeanManagerReference() { - return beanManagerReference; + return options.getBeanManagerReference(); } @Override public Object getValidatorFactoryReference() { - return validatorFactoryReference; + return options.getValidatorFactoryReference(); } @Override public String getSessionFactoryName() { - return sessionFactoryName; + return options.getSessionFactoryName(); } @Override public boolean isSessionFactoryNameAlsoJndiName() { - return sessionFactoryNameAlsoJndiName; + return options.isSessionFactoryNameAlsoJndiName(); } @Override public boolean isFlushBeforeCompletionEnabled() { - return flushBeforeCompletionEnabled; + return options.isFlushBeforeCompletionEnabled(); } @Override public boolean isAutoCloseSessionEnabled() { - return autoCloseSessionEnabled; + return options.isAutoCloseSessionEnabled(); } @Override public boolean isStatisticsEnabled() { - return statisticsEnabled; + return options.isStatisticsEnabled(); } @Override public Interceptor getInterceptor() { - return interceptor == null ? EmptyInterceptor.INSTANCE : interceptor; + return options.getInterceptor(); } @Override public SessionFactoryObserver[] getSessionFactoryObservers() { - return sessionFactoryObserverList.toArray( new SessionFactoryObserver[ sessionFactoryObserverList.size() ] ); + return options.getSessionFactoryObservers(); } @Override public BaselineSessionEventsListenerBuilder getBaselineSessionEventsListenerBuilder() { - return baselineSessionEventsListenerBuilder; + return options.getBaselineSessionEventsListenerBuilder(); } @Override public boolean isIdentifierRollbackEnabled() { - return identifierRollbackEnabled; + return options.isIdentifierRollbackEnabled(); } @Override public EntityMode getDefaultEntityMode() { - return defaultEntityMode; + return options.getDefaultEntityMode(); } @Override public EntityTuplizerFactory getEntityTuplizerFactory() { - return entityTuplizerFactory; + return options.getEntityTuplizerFactory(); } @Override public boolean isCheckNullability() { - return checkNullability; + return options.isCheckNullability(); } @Override public boolean isInitializeLazyStateOutsideTransactionsEnabled() { - return initializeLazyStateOutsideTransactions; + return options.isInitializeLazyStateOutsideTransactionsEnabled(); } @Override public MultiTableBulkIdStrategy getMultiTableBulkIdStrategy() { - return multiTableBulkIdStrategy; + return options.getMultiTableBulkIdStrategy(); } @Override public BatchFetchStyle getBatchFetchStyle() { - return batchFetchStyle; + return options.getBatchFetchStyle(); } @Override public int getDefaultBatchFetchSize() { - return defaultBatchFetchSize; + return options.getDefaultBatchFetchSize(); } @Override public Integer getMaximumFetchDepth() { - return maximumFetchDepth; + return options.getMaximumFetchDepth(); } @Override public NullPrecedence getDefaultNullPrecedence() { - return defaultNullPrecedence; + return options.getDefaultNullPrecedence(); } @Override public boolean isOrderUpdatesEnabled() { - return orderUpdatesEnabled; + return options.isOrderUpdatesEnabled(); } @Override public boolean isOrderInsertsEnabled() { - return orderInsertsEnabled; + return options.isOrderInsertsEnabled(); } @Override public MultiTenancyStrategy getMultiTenancyStrategy() { - return multiTenancyStrategy; + return options.getMultiTenancyStrategy(); } @Override public CurrentTenantIdentifierResolver getCurrentTenantIdentifierResolver() { - return currentTenantIdentifierResolver; + return options.getCurrentTenantIdentifierResolver(); } @Override public boolean isJtaTrackByThread() { - return jtaTrackByThread; + return options.isJtaTrackByThread(); } @Override public Map getQuerySubstitutions() { - return querySubstitutions; + return options.getQuerySubstitutions(); } @Override public boolean isStrictJpaQueryLanguageCompliance() { - return strictJpaQueryLanguageCompliance; + return options.isStrictJpaQueryLanguageCompliance(); } @Override public boolean isNamedQueryStartupCheckingEnabled() { - return namedQueryStartupCheckingEnabled; + return options.isNamedQueryStartupCheckingEnabled(); } @Override public boolean isSecondLevelCacheEnabled() { - return secondLevelCacheEnabled; + return options.isSecondLevelCacheEnabled(); } @Override public boolean isQueryCacheEnabled() { - return queryCacheEnabled; + return options.isQueryCacheEnabled(); } @Override public QueryCacheFactory getQueryCacheFactory() { - return queryCacheFactory; + return options.getQueryCacheFactory(); } @Override public String getCacheRegionPrefix() { - return cacheRegionPrefix; + return options.getCacheRegionPrefix(); } @Override public boolean isMinimalPutsEnabled() { - return minimalPutsEnabled; + return options.isMinimalPutsEnabled(); } @Override public boolean isStructuredCacheEntriesEnabled() { - return structuredCacheEntriesEnabled; + return options.isStructuredCacheEntriesEnabled(); } @Override public boolean isDirectReferenceCacheEntriesEnabled() { - return directReferenceCacheEntriesEnabled; + return options.isDirectReferenceCacheEntriesEnabled(); } @Override public boolean isAutoEvictCollectionCache() { - return autoEvictCollectionCache; + return options.isAutoEvictCollectionCache(); } @Override public SchemaAutoTooling getSchemaAutoTooling() { - return schemaAutoTooling; + return options.getSchemaAutoTooling(); } @Override public boolean isDataDefinitionImplicitCommit() { - return dataDefinitionImplicitCommit; + return options.isDataDefinitionImplicitCommit(); } @Override public boolean isDataDefinitionInTransactionSupported() { - return dataDefinitionInTransactionSupported; + return options.isDataDefinitionInTransactionSupported(); } @Override public int getJdbcBatchSize() { - return jdbcBatchSize; + return options.getJdbcBatchSize(); } @Override public boolean isJdbcBatchVersionedData() { - return jdbcBatchVersionedData; + return options.isJdbcBatchVersionedData(); } @Override public boolean isScrollableResultSetsEnabled() { - return scrollableResultSetsEnabled; + return options.isScrollableResultSetsEnabled(); } @Override public boolean isWrapResultSetsEnabled() { - return wrapResultSetsEnabled; + return options.isWrapResultSetsEnabled(); } @Override public boolean isGetGeneratedKeysEnabled() { - return getGeneratedKeysEnabled; + return options.isGetGeneratedKeysEnabled(); } @Override public Integer getJdbcFetchSize() { - return jdbcFetchSize; + return options.getJdbcFetchSize(); } @Override public ConnectionReleaseMode getConnectionReleaseMode() { - return connectionReleaseMode; + return options.getConnectionReleaseMode(); } @Override public boolean isCommentsEnabled() { - return commentsEnabled; + return options.isCommentsEnabled(); } @Override public CustomEntityDirtinessStrategy getCustomEntityDirtinessStrategy() { - return customEntityDirtinessStrategy; + return options.getCustomEntityDirtinessStrategy(); } @Override public EntityNameResolver[] getEntityNameResolvers() { - return entityNameResolvers.toArray( new EntityNameResolver[ entityNameResolvers.size() ] ); + return options.getEntityNameResolvers(); } @Override public EntityNotFoundDelegate getEntityNotFoundDelegate() { - return entityNotFoundDelegate; + return options.getEntityNotFoundDelegate(); } @Override public Map getCustomSqlFunctionMap() { - return sqlFunctions == null ? Collections.emptyMap() : sqlFunctions; + return options.getCustomSqlFunctionMap(); } } diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/CacheTestUtil.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/CacheTestUtil.java index 004f769e1b..9749ba3b05 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/CacheTestUtil.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/CacheTestUtil.java @@ -27,6 +27,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Properties; +import org.hibernate.boot.internal.SessionFactoryBuilderImpl; import org.hibernate.boot.internal.SessionFactoryOptionsImpl; import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; @@ -103,7 +104,11 @@ public class CacheTestUtil { regionFactory = (InfinispanRegionFactory) clazz.newInstance(); } - final SessionFactoryOptionsImpl sessionFactoryOptions = new SessionFactoryOptionsImpl( (StandardServiceRegistry) serviceRegistry ); + final SessionFactoryOptionsImpl sessionFactoryOptions = new SessionFactoryOptionsImpl( + new SessionFactoryBuilderImpl.SessionFactoryOptionsStateStandardImpl( + (StandardServiceRegistry) serviceRegistry + ) + ); final Settings settings = new Settings( sessionFactoryOptions ); final Properties properties = toProperties( cfgService.getSettings() );