HHH-9727 - Slight redesign to bootstrapping APIs to allow for OGM bootstrapping
This commit is contained in:
parent
e8af41637f
commit
d2c50f16f2
|
@ -121,6 +121,336 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement
|
|||
private static final Logger log = Logger.getLogger( SessionFactoryBuilderImpl.class );
|
||||
|
||||
private final MetadataImplementor metadata;
|
||||
private final SessionFactoryOptionsStateStandardImpl options;
|
||||
|
||||
SessionFactoryBuilderImpl(MetadataImplementor metadata) {
|
||||
this.metadata = metadata;
|
||||
this.options = new SessionFactoryOptionsStateStandardImpl( metadata.getMetadataBuildingOptions().getServiceRegistry() );
|
||||
|
||||
if ( metadata.getSqlFunctionMap() != null ) {
|
||||
for ( Map.Entry<String, SQLFunction> sqlFunctionEntry : metadata.getSqlFunctionMap().entrySet() ) {
|
||||
applySqlFunction( sqlFunctionEntry.getKey(), sqlFunctionEntry.getValue() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyValidatorFactory(Object validatorFactory) {
|
||||
this.options.validatorFactoryReference = validatorFactory;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyBeanManager(Object beanManager) {
|
||||
this.options.beanManagerReference = beanManager;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyName(String sessionFactoryName) {
|
||||
this.options.sessionFactoryName = sessionFactoryName;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyNameAsJndiName(boolean isJndiName) {
|
||||
this.options.sessionFactoryNameAlsoJndiName = isJndiName;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyAutoClosing(boolean enabled) {
|
||||
this.options.autoCloseSessionEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyAutoFlushing(boolean enabled) {
|
||||
this.options.flushBeforeCompletionEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyStatisticsSupport(boolean enabled) {
|
||||
this.options.statisticsEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder addSessionFactoryObservers(SessionFactoryObserver... observers) {
|
||||
this.options.sessionFactoryObserverList.addAll( Arrays.asList( observers ) );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyInterceptor(Interceptor interceptor) {
|
||||
this.options.interceptor = interceptor;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyCustomEntityDirtinessStrategy(CustomEntityDirtinessStrategy strategy) {
|
||||
this.options.customEntityDirtinessStrategy = strategy;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder addEntityNameResolver(EntityNameResolver... entityNameResolvers) {
|
||||
this.options.entityNameResolvers.addAll( Arrays.asList( entityNameResolvers ) );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyEntityNotFoundDelegate(EntityNotFoundDelegate entityNotFoundDelegate) {
|
||||
this.options.entityNotFoundDelegate = entityNotFoundDelegate;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyIdentifierRollbackSupport(boolean enabled) {
|
||||
this.options.identifierRollbackEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyDefaultEntityMode(EntityMode entityMode) {
|
||||
this.options.defaultEntityMode = entityMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyNullabilityChecking(boolean enabled) {
|
||||
this.options.checkNullability = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyLazyInitializationOutsideTransaction(boolean enabled) {
|
||||
this.options.initializeLazyStateOutsideTransactions = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyEntityTuplizerFactory(EntityTuplizerFactory entityTuplizerFactory) {
|
||||
this.options.entityTuplizerFactory = entityTuplizerFactory;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyEntityTuplizer(
|
||||
EntityMode entityMode,
|
||||
Class<? extends EntityTuplizer> tuplizerClass) {
|
||||
this.options.entityTuplizerFactory.registerDefaultTuplizerClass( entityMode, tuplizerClass );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyMultiTableBulkIdStrategy(MultiTableBulkIdStrategy strategy) {
|
||||
this.options.multiTableBulkIdStrategy = strategy;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyBatchFetchStyle(BatchFetchStyle style) {
|
||||
this.options.batchFetchStyle = style;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyDefaultBatchFetchSize(int size) {
|
||||
this.options.defaultBatchFetchSize = size;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyMaximumFetchDepth(int depth) {
|
||||
this.options.maximumFetchDepth = depth;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyDefaultNullPrecedence(NullPrecedence nullPrecedence) {
|
||||
this.options.defaultNullPrecedence = nullPrecedence;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyOrderingOfInserts(boolean enabled) {
|
||||
this.options.orderInsertsEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyOrderingOfUpdates(boolean enabled) {
|
||||
this.options.orderUpdatesEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyMultiTenancyStrategy(MultiTenancyStrategy strategy) {
|
||||
this.options.multiTenancyStrategy = strategy;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyCurrentTenantIdentifierResolver(CurrentTenantIdentifierResolver resolver) {
|
||||
this.options.currentTenantIdentifierResolver = resolver;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyJtaTrackingByThread(boolean enabled) {
|
||||
this.options.jtaTrackByThread = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public SessionFactoryBuilder applyQuerySubstitutions(Map substitutions) {
|
||||
this.options.querySubstitutions.putAll( substitutions );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyStrictJpaQueryLanguageCompliance(boolean enabled) {
|
||||
this.options.strictJpaQueryLanguageCompliance = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyNamedQueryCheckingOnStartup(boolean enabled) {
|
||||
this.options.namedQueryStartupCheckingEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applySecondLevelCacheSupport(boolean enabled) {
|
||||
this.options.secondLevelCacheEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyQueryCacheSupport(boolean enabled) {
|
||||
this.options.queryCacheEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyQueryCacheFactory(QueryCacheFactory factory) {
|
||||
this.options.queryCacheFactory = factory;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyCacheRegionPrefix(String prefix) {
|
||||
this.options.cacheRegionPrefix = prefix;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyMinimalPutsForCaching(boolean enabled) {
|
||||
this.options.minimalPutsEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyStructuredCacheEntries(boolean enabled) {
|
||||
this.options.structuredCacheEntriesEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyDirectReferenceCaching(boolean enabled) {
|
||||
this.options.directReferenceCacheEntriesEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyAutomaticEvictionOfCollectionCaches(boolean enabled) {
|
||||
this.options.autoEvictCollectionCache = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyJdbcBatchSize(int size) {
|
||||
this.options.jdbcBatchSize = size;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyJdbcBatchingForVersionedEntities(boolean enabled) {
|
||||
this.options.jdbcBatchVersionedData = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyScrollableResultsSupport(boolean enabled) {
|
||||
this.options.scrollableResultSetsEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyResultSetsWrapping(boolean enabled) {
|
||||
this.options.wrapResultSetsEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyGetGeneratedKeysSupport(boolean enabled) {
|
||||
this.options.getGeneratedKeysEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyJdbcFetchSize(int size) {
|
||||
this.options.jdbcFetchSize = size;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyConnectionReleaseMode(ConnectionReleaseMode connectionReleaseMode) {
|
||||
this.options.connectionReleaseMode = connectionReleaseMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applySqlComments(boolean enabled) {
|
||||
this.options.commentsEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applySqlFunction(String registrationName, SQLFunction sqlFunction) {
|
||||
if ( this.options.sqlFunctions == null ) {
|
||||
this.options.sqlFunctions = new HashMap<String, SQLFunction>();
|
||||
}
|
||||
this.options.sqlFunctions.put( registrationName, sqlFunction );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends SessionFactoryBuilder> T unwrap(Class<T> type) {
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactory build() {
|
||||
metadata.validate();
|
||||
return new SessionFactoryImpl( metadata, buildSessionFactoryOptions() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryOptions buildSessionFactoryOptions() {
|
||||
return new SessionFactoryOptionsImpl( this );
|
||||
}
|
||||
|
||||
|
||||
|
||||
// SessionFactoryOptionsState impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
public static class SessionFactoryOptionsStateStandardImpl implements SessionFactoryOptionsState {
|
||||
private final StandardServiceRegistry serviceRegistry;
|
||||
|
||||
// integration
|
||||
|
@ -197,14 +527,9 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement
|
|||
|
||||
private Map<String, SQLFunction> sqlFunctions;
|
||||
|
||||
SessionFactoryBuilderImpl(MetadataImplementor metadata) {
|
||||
this.metadata = metadata;
|
||||
this.serviceRegistry = metadata.getMetadataBuildingOptions().getServiceRegistry();
|
||||
public SessionFactoryOptionsStateStandardImpl(StandardServiceRegistry serviceRegistry) {
|
||||
this.serviceRegistry = serviceRegistry;
|
||||
|
||||
initializeState();
|
||||
}
|
||||
|
||||
private void initializeState() {
|
||||
final StrategySelector strategySelector = serviceRegistry.getService( StrategySelector.class );
|
||||
ConfigurationService cfgService = serviceRegistry.getService( ConfigurationService.class );
|
||||
final JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class );
|
||||
|
@ -351,329 +676,7 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement
|
|||
}
|
||||
|
||||
this.commentsEnabled = ConfigurationHelper.getBoolean( USE_SQL_COMMENTS, configurationSettings );
|
||||
|
||||
if ( metadata.getSqlFunctionMap() != null ) {
|
||||
for ( Map.Entry<String, SQLFunction> sqlFunctionEntry : metadata.getSqlFunctionMap().entrySet() ) {
|
||||
applySqlFunction( sqlFunctionEntry.getKey(), sqlFunctionEntry.getValue() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyValidatorFactory(Object validatorFactory) {
|
||||
this.validatorFactoryReference = validatorFactory;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyBeanManager(Object beanManager) {
|
||||
this.beanManagerReference = beanManager;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyName(String sessionFactoryName) {
|
||||
this.sessionFactoryName = sessionFactoryName;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyNameAsJndiName(boolean isJndiName) {
|
||||
this.sessionFactoryNameAlsoJndiName = isJndiName;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyAutoClosing(boolean enabled) {
|
||||
this.autoCloseSessionEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyAutoFlushing(boolean enabled) {
|
||||
this.flushBeforeCompletionEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyStatisticsSupport(boolean enabled) {
|
||||
this.statisticsEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder addSessionFactoryObservers(SessionFactoryObserver... observers) {
|
||||
this.sessionFactoryObserverList.addAll( Arrays.asList( observers ) );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyInterceptor(Interceptor interceptor) {
|
||||
this.interceptor = interceptor;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyCustomEntityDirtinessStrategy(CustomEntityDirtinessStrategy strategy) {
|
||||
this.customEntityDirtinessStrategy = strategy;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder addEntityNameResolver(EntityNameResolver... entityNameResolvers) {
|
||||
this.entityNameResolvers.addAll( Arrays.asList( entityNameResolvers ) );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyEntityNotFoundDelegate(EntityNotFoundDelegate entityNotFoundDelegate) {
|
||||
this.entityNotFoundDelegate = entityNotFoundDelegate;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyIdentifierRollbackSupport(boolean enabled) {
|
||||
this.identifierRollbackEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyDefaultEntityMode(EntityMode entityMode) {
|
||||
this.defaultEntityMode = entityMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyNullabilityChecking(boolean enabled) {
|
||||
this.checkNullability = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyLazyInitializationOutsideTransaction(boolean enabled) {
|
||||
this.initializeLazyStateOutsideTransactions = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyEntityTuplizerFactory(EntityTuplizerFactory entityTuplizerFactory) {
|
||||
this.entityTuplizerFactory = entityTuplizerFactory;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyEntityTuplizer(
|
||||
EntityMode entityMode,
|
||||
Class<? extends EntityTuplizer> tuplizerClass) {
|
||||
this.entityTuplizerFactory.registerDefaultTuplizerClass( entityMode, tuplizerClass );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyMultiTableBulkIdStrategy(MultiTableBulkIdStrategy strategy) {
|
||||
this.multiTableBulkIdStrategy = strategy;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyBatchFetchStyle(BatchFetchStyle style) {
|
||||
this.batchFetchStyle = style;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyDefaultBatchFetchSize(int size) {
|
||||
this.defaultBatchFetchSize = size;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyMaximumFetchDepth(int depth) {
|
||||
this.maximumFetchDepth = depth;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyDefaultNullPrecedence(NullPrecedence nullPrecedence) {
|
||||
this.defaultNullPrecedence = nullPrecedence;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyOrderingOfInserts(boolean enabled) {
|
||||
this.orderInsertsEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyOrderingOfUpdates(boolean enabled) {
|
||||
this.orderUpdatesEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyMultiTenancyStrategy(MultiTenancyStrategy strategy) {
|
||||
this.multiTenancyStrategy = strategy;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyCurrentTenantIdentifierResolver(CurrentTenantIdentifierResolver resolver) {
|
||||
this.currentTenantIdentifierResolver = resolver;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyJtaTrackingByThread(boolean enabled) {
|
||||
this.jtaTrackByThread = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public SessionFactoryBuilder applyQuerySubstitutions(Map substitutions) {
|
||||
this.querySubstitutions.putAll( substitutions );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyStrictJpaQueryLanguageCompliance(boolean enabled) {
|
||||
this.strictJpaQueryLanguageCompliance = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyNamedQueryCheckingOnStartup(boolean enabled) {
|
||||
this.namedQueryStartupCheckingEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applySecondLevelCacheSupport(boolean enabled) {
|
||||
this.secondLevelCacheEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyQueryCacheSupport(boolean enabled) {
|
||||
this.queryCacheEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyQueryCacheFactory(QueryCacheFactory factory) {
|
||||
this.queryCacheFactory = factory;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyCacheRegionPrefix(String prefix) {
|
||||
this.cacheRegionPrefix = prefix;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyMinimalPutsForCaching(boolean enabled) {
|
||||
this.minimalPutsEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyStructuredCacheEntries(boolean enabled) {
|
||||
this.structuredCacheEntriesEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyDirectReferenceCaching(boolean enabled) {
|
||||
this.directReferenceCacheEntriesEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyAutomaticEvictionOfCollectionCaches(boolean enabled) {
|
||||
this.autoEvictCollectionCache = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyJdbcBatchSize(int size) {
|
||||
this.jdbcBatchSize = size;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyJdbcBatchingForVersionedEntities(boolean enabled) {
|
||||
this.jdbcBatchVersionedData = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyScrollableResultsSupport(boolean enabled) {
|
||||
this.scrollableResultSetsEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyResultSetsWrapping(boolean enabled) {
|
||||
this.wrapResultSetsEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyGetGeneratedKeysSupport(boolean enabled) {
|
||||
this.getGeneratedKeysEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyJdbcFetchSize(int size) {
|
||||
this.jdbcFetchSize = size;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyConnectionReleaseMode(ConnectionReleaseMode connectionReleaseMode) {
|
||||
this.connectionReleaseMode = connectionReleaseMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applySqlComments(boolean enabled) {
|
||||
this.commentsEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applySqlFunction(String registrationName, SQLFunction sqlFunction) {
|
||||
if ( this.sqlFunctions == null ) {
|
||||
this.sqlFunctions = new HashMap<String, SQLFunction>();
|
||||
}
|
||||
this.sqlFunctions.put( registrationName, sqlFunction );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends SessionFactoryBuilder> T unwrap(Class<T> type) {
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactory build() {
|
||||
metadata.validate();
|
||||
return new SessionFactoryImpl( metadata, buildSessionFactoryOptions() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryOptions buildSessionFactoryOptions() {
|
||||
return new SessionFactoryOptionsImpl( this );
|
||||
}
|
||||
|
||||
|
||||
|
||||
// SessionFactoryOptionsState impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@Override
|
||||
public StandardServiceRegistry getServiceRegistry() {
|
||||
|
@ -934,4 +937,266 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement
|
|||
public Map<String, SQLFunction> getCustomSqlFunctionMap() {
|
||||
return sqlFunctions == null ? Collections.<String, SQLFunction>emptyMap() : sqlFunctions;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public StandardServiceRegistry getServiceRegistry() {
|
||||
return options.getServiceRegistry();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getBeanManagerReference() {
|
||||
return options.getBeanManagerReference();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValidatorFactoryReference() {
|
||||
return options.getValidatorFactoryReference();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSessionFactoryName() {
|
||||
return options.getSessionFactoryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSessionFactoryNameAlsoJndiName() {
|
||||
return options.isSessionFactoryNameAlsoJndiName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFlushBeforeCompletionEnabled() {
|
||||
return options.isFlushBeforeCompletionEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoCloseSessionEnabled() {
|
||||
return options.isAutoCloseSessionEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStatisticsEnabled() {
|
||||
return options.isStatisticsEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interceptor getInterceptor() {
|
||||
return options.getInterceptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryObserver[] getSessionFactoryObservers() {
|
||||
return options.getSessionFactoryObservers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaselineSessionEventsListenerBuilder getBaselineSessionEventsListenerBuilder() {
|
||||
return options.getBaselineSessionEventsListenerBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIdentifierRollbackEnabled() {
|
||||
return options.isIdentifierRollbackEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityMode getDefaultEntityMode() {
|
||||
return options.getDefaultEntityMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityTuplizerFactory getEntityTuplizerFactory() {
|
||||
return options.getEntityTuplizerFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCheckNullability() {
|
||||
return options.isCheckNullability();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInitializeLazyStateOutsideTransactionsEnabled() {
|
||||
return options.isInitializeLazyStateOutsideTransactionsEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiTableBulkIdStrategy getMultiTableBulkIdStrategy() {
|
||||
return options.getMultiTableBulkIdStrategy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BatchFetchStyle getBatchFetchStyle() {
|
||||
return options.getBatchFetchStyle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefaultBatchFetchSize() {
|
||||
return options.getDefaultBatchFetchSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getMaximumFetchDepth() {
|
||||
return options.getMaximumFetchDepth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NullPrecedence getDefaultNullPrecedence() {
|
||||
return options.getDefaultNullPrecedence();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOrderUpdatesEnabled() {
|
||||
return options.isOrderUpdatesEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOrderInsertsEnabled() {
|
||||
return options.isOrderInsertsEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiTenancyStrategy getMultiTenancyStrategy() {
|
||||
return options.getMultiTenancyStrategy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CurrentTenantIdentifierResolver getCurrentTenantIdentifierResolver() {
|
||||
return options.getCurrentTenantIdentifierResolver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJtaTrackByThread() {
|
||||
return options.isJtaTrackByThread();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map getQuerySubstitutions() {
|
||||
return options.getQuerySubstitutions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStrictJpaQueryLanguageCompliance() {
|
||||
return options.isStrictJpaQueryLanguageCompliance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNamedQueryStartupCheckingEnabled() {
|
||||
return options.isNamedQueryStartupCheckingEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecondLevelCacheEnabled() {
|
||||
return options.isSecondLevelCacheEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isQueryCacheEnabled() {
|
||||
return options.isQueryCacheEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryCacheFactory getQueryCacheFactory() {
|
||||
return options.getQueryCacheFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCacheRegionPrefix() {
|
||||
return options.getCacheRegionPrefix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMinimalPutsEnabled() {
|
||||
return options.isMinimalPutsEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStructuredCacheEntriesEnabled() {
|
||||
return options.isStructuredCacheEntriesEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirectReferenceCacheEntriesEnabled() {
|
||||
return options.isDirectReferenceCacheEntriesEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoEvictCollectionCache() {
|
||||
return options.isAutoEvictCollectionCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchemaAutoTooling getSchemaAutoTooling() {
|
||||
return options.getSchemaAutoTooling();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDataDefinitionImplicitCommit() {
|
||||
return options.isDataDefinitionImplicitCommit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDataDefinitionInTransactionSupported() {
|
||||
return options.isDataDefinitionInTransactionSupported();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getJdbcBatchSize() {
|
||||
return options.getJdbcBatchSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJdbcBatchVersionedData() {
|
||||
return options.isJdbcBatchVersionedData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isScrollableResultSetsEnabled() {
|
||||
return options.isScrollableResultSetsEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWrapResultSetsEnabled() {
|
||||
return options.isWrapResultSetsEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGetGeneratedKeysEnabled() {
|
||||
return options.isGetGeneratedKeysEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getJdbcFetchSize() {
|
||||
return options.getJdbcFetchSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConnectionReleaseMode getConnectionReleaseMode() {
|
||||
return options.getConnectionReleaseMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommentsEnabled() {
|
||||
return options.isCommentsEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomEntityDirtinessStrategy getCustomEntityDirtinessStrategy() {
|
||||
return options.getCustomEntityDirtinessStrategy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNameResolver[] getEntityNameResolvers() {
|
||||
return options.getEntityNameResolvers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNotFoundDelegate getEntityNotFoundDelegate() {
|
||||
return options.getEntityNotFoundDelegate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, SQLFunction> getCustomSqlFunctionMap() {
|
||||
return options.getCustomSqlFunctionMap();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() );
|
||||
|
||||
|
|
Loading…
Reference in New Issue