Package org.hibernate.boot.spi
Class AbstractDelegatingSessionFactoryBuilder<T extends SessionFactoryBuilder>
- java.lang.Object
-
- org.hibernate.boot.spi.AbstractDelegatingSessionFactoryBuilder<T>
-
- Type Parameters:
T- The type of a specific sub-class; Allows sub-classes to narrow down the return-type of the contract methods to a specialization ofSessionFactoryBuilder
- All Implemented Interfaces:
SessionFactoryBuilder
- Direct Known Subclasses:
AbstractDelegatingSessionFactoryBuilderImplementor
public abstract class AbstractDelegatingSessionFactoryBuilder<T extends SessionFactoryBuilder> extends java.lang.Object implements SessionFactoryBuilder
Convenience base class for custom implementors of SessionFactoryBuilder, using delegation
-
-
Constructor Summary
Constructors Constructor Description AbstractDelegatingSessionFactoryBuilder(SessionFactoryBuilder delegate)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description TaddEntityNameResolver(EntityNameResolver... entityNameResolvers)Specifies one or more entity name resolvers to be applied to the SessionFactory (see theEntityNameResolvercontract for more information..TaddSessionFactoryObservers(SessionFactoryObserver... observers)Specifies one or more observers to be applied to the SessionFactory.TallowOutOfTransactionUpdateOperations(boolean allow)TapplyAutoClosing(boolean enabled)Applies whether Sessions should be automatically closed at the end of the transaction.TapplyAutoFlushing(boolean enabled)Applies whether Sessions should be automatically flushed at the end of the transaction.TapplyAutomaticEvictionOfCollectionCaches(boolean enabled)When using bi-directional many-to-one associations and caching the one-to-many side it is expected that both sides of the association are managed (actually that is true of all bi-directional associations).TapplyBatchFetchStyle(BatchFetchStyle style)What style of batching should be used?TapplyBeanManager(java.lang.Object beanManager)Apply a CDI BeanManager to the SessionFactory being built.TapplyCacheRegionPrefix(java.lang.String prefix)Apply a prefix to prepended to all cache region names for this SessionFactory.TapplyConnectionHandlingMode(PhysicalConnectionHandlingMode connectionHandlingMode)Apply the specified handling mode for JDBC connectionsSessionFactoryBuilderapplyConnectionProviderDisablesAutoCommit(boolean providerDisablesAutoCommit)TapplyConnectionReleaseMode(ConnectionReleaseMode connectionReleaseMode)Apply a ConnectionReleaseMode.TapplyCurrentTenantIdentifierResolver(CurrentTenantIdentifierResolver resolver)Specifies a strategy for resolving the notion of a "current" tenant-identifier when using multi-tenancy together with current sessionsTapplyCustomEntityDirtinessStrategy(CustomEntityDirtinessStrategy strategy)Specifies a custom entity dirtiness strategy to be applied to the SessionFactory.TapplyDefaultBatchFetchSize(int size)Allows specifying a default batch-fetch size for all entities and collections which do not otherwise specify a batch-fetch size.TapplyDefaultEntityMode(EntityMode entityMode)Applies the given entity mode as the default for the SessionFactory.TapplyDefaultNullPrecedence(NullPrecedence nullPrecedence)Apply a null precedence (NULLS FIRST, NULLS LAST) to be applied order-by clauses rendered into SQL queries.SessionFactoryBuilderapplyDelayedEntityLoaderCreations(boolean delay)Should entity Loaders be generated immediately? Or should the creation be delayed until first need?TapplyDirectReferenceCaching(boolean enabled)Generally, Hibernate will extract the information from an entity and put that extracted information into the second-level cache.TapplyEntityNotFoundDelegate(EntityNotFoundDelegate entityNotFoundDelegate)Names theEntityNotFoundDelegateto be applied to the SessionFactory.TapplyEntityTuplizer(EntityMode entityMode, java.lang.Class<? extends EntityTuplizer> tuplizerClass)Register the defaultEntityTuplizerto be applied to the SessionFactory.TapplyEntityTuplizerFactory(EntityTuplizerFactory entityTuplizerFactory)Specify the EntityTuplizerFactory to use.TapplyGetGeneratedKeysSupport(boolean enabled)Should JDBCStatement.getGeneratedKeys()feature be used for retrieval of *insert-generated* ids?TapplyIdentifierRollbackSupport(boolean enabled)Should generated identifiers be "unset" on entities during a rollback?TapplyInterceptor(Interceptor interceptor)Names an interceptor to be applied to the SessionFactory, which in turn means it will be used by all Sessions unless one is explicitly specified inSessionBuilder.interceptor(org.hibernate.Interceptor)TapplyJdbcBatchingForVersionedEntities(boolean enabled)This setting controls whether versioned entities will be included in JDBC batching.TapplyJdbcBatchSize(int size)Specifies the maximum number of statements to batch together in a JDBC batch for insert, update and delete operations.TapplyJdbcFetchSize(int size)Apply a fetch size to the JDBC driver for fetching results.TapplyJtaTrackingByThread(boolean enabled)If using the built-in Hibernate JTA-based TransactionCoordinator/Builder, should it track JTA transactions by thread in an attempt to detect timeouts?TapplyLazyInitializationOutsideTransaction(boolean enabled)Should the application be allowed to initialize uninitialized lazy state outside the bounds of a transaction?TapplyMaximumFetchDepth(int depth)Apply a limit to the depth Hibernate will use for outer joins.TapplyMinimalPutsForCaching(boolean enabled)By default, Hibernate will always just push data into the cache without first checking if that data already exists.TapplyMultiTableBulkIdStrategy(MultiTableBulkIdStrategy strategy)How should updates and deletes that span multiple tables be handled?TapplyMultiTenancyStrategy(MultiTenancyStrategy strategy)Apply the form of multi-tenancy used by the applicationTapplyName(java.lang.String sessionFactoryName)Applies a SessionFactory name.TapplyNameAsJndiName(boolean isJndiName)Applies a SessionFactory name.TapplyNamedQueryCheckingOnStartup(boolean enabled)Should named queries be checked on startup?TapplyNullabilityChecking(boolean enabled)Should attributes using columns marked as not-null be checked (by Hibernate) for nullness?TapplyOrderingOfInserts(boolean enabled)Apply whether ordering of inserts should be enabled.TapplyOrderingOfUpdates(boolean enabled)Apply whether ordering of updates should be enabled.TapplyPreferUserTransactions(boolean preferUserTransactions)If using the built-in Hibernate JTA-based TransactionCoordinator/Builder, should it prefer to useUserTransactionoverTransaction?TapplyQueryCacheSupport(boolean enabled)Should second level query caching support be enabled?TapplyQuerySubstitutions(java.util.Map substitutions)Apply query substitutions to use in HQL queries.TapplyResultSetsWrapping(boolean enabled)Hibernate currently accesses results from the JDBC ResultSet by name.TapplyScrollableResultsSupport(boolean enabled)Should scrollable results be supported in queries? We ask the JDBC driver whether it supports scrollable result sets as the default for this setting, but some drivers do not accurately report this via DatabaseMetaData.TapplySecondLevelCacheSupport(boolean enabled)Should second level caching support be enabled?TapplySqlComments(boolean enabled)Should Hibernate apply comments to SQL it generates?TapplySqlFunction(java.lang.String registrationName, SQLFunction sqlFunction)Apply a SQLFunction to the underlyingSQLFunctionRegistry.TapplyStatelessInterceptor(java.lang.Class<? extends Interceptor> statelessInterceptorClass)Names an interceptor Class to be applied to the SessionFactory, which in turn means it will be used by all Sessions unless one is explicitly specified inSessionBuilder.interceptor(org.hibernate.Interceptor)TapplyStatelessInterceptor(java.util.function.Supplier<? extends Interceptor> statelessInterceptorSupplier)Names aSupplierinstance which is used to retrieve the interceptor to be applied to the SessionFactory, which in turn means it will be used by all Sessions unless one is explicitly specified inSessionBuilder.interceptor(org.hibernate.Interceptor)TapplyStatementInspector(StatementInspector statementInspector)Names a StatementInspector to be applied to the SessionFactory, which in turn means it will be used by all Sessions unless one is explicitly specified inSessionBuilder.statementInspector(org.hibernate.resource.jdbc.spi.StatementInspector)TapplyStatisticsSupport(boolean enabled)Applies whether statistics gathering is enabled.TapplyStrictJpaQueryLanguageCompliance(boolean enabled)Should we strictly adhere to JPA Query Language (JPQL) syntax, or more broadly support all of Hibernate's superset (HQL)?TapplyStructuredCacheEntries(boolean enabled)By default, Hibernate stores data in the cache in its own optimized format.TapplyTempTableDdlTransactionHandling(TempTableDdlTransactionHandling handling)SessionFactoryBuilderapplyTimestampsCacheFactory(TimestampsCacheFactory factory)Specifies a QueryCacheFactory to use for building query cache handlers.TapplyValidatorFactory(java.lang.Object validatorFactory)Apply a Bean Validation ValidatorFactory to the SessionFactory being built.SessionFactorybuild()After all options have been set, build the SessionFactory.protected SessionFactoryBuilderdelegate()SessionFactoryBuilderenableJpaClosedCompliance(boolean enabled)SessionFactoryBuilderenableJpaListCompliance(boolean enabled)SessionFactoryBuilderenableJpaQueryCompliance(boolean enabled)SessionFactoryBuilderenableJpaTransactionCompliance(boolean enabled)TenableReleaseResourcesOnCloseEnabled(boolean enable)Should resources held byEntityManagerinstance be released immediately on close?protected abstract TgetThis()Returns a specific implementation.<S extends SessionFactoryBuilder>
Sunwrap(java.lang.Class<S> type)Allows unwrapping this builder as another, more specific type.
-
-
-
Constructor Detail
-
AbstractDelegatingSessionFactoryBuilder
public AbstractDelegatingSessionFactoryBuilder(SessionFactoryBuilder delegate)
-
-
Method Detail
-
getThis
protected abstract T getThis()
Returns a specific implementation. See the What is the "getThis trick?".
-
delegate
protected SessionFactoryBuilder delegate()
-
applyValidatorFactory
public T applyValidatorFactory(java.lang.Object validatorFactory)
Description copied from interface:SessionFactoryBuilderApply a Bean Validation ValidatorFactory to the SessionFactory being built. NOTE : De-typed to avoid hard dependency on Bean Validation jar at runtime.- Specified by:
applyValidatorFactoryin interfaceSessionFactoryBuilder- Parameters:
validatorFactory- The Bean Validation ValidatorFactory to use- Returns:
this, for method chaining
-
applyBeanManager
public T applyBeanManager(java.lang.Object beanManager)
Description copied from interface:SessionFactoryBuilderApply a CDI BeanManager to the SessionFactory being built. NOTE : De-typed to avoid hard dependency on CDI jar at runtime.- Specified by:
applyBeanManagerin interfaceSessionFactoryBuilder- Parameters:
beanManager- The CDI BeanManager to use- Returns:
this, for method chaining
-
applyName
public T applyName(java.lang.String sessionFactoryName)
Description copied from interface:SessionFactoryBuilderApplies a SessionFactory name.- Specified by:
applyNamein interfaceSessionFactoryBuilder- Parameters:
sessionFactoryName- The name to use for the SessionFactory being built- Returns:
this, for method chaining- See Also:
AvailableSettings.SESSION_FACTORY_NAME
-
applyNameAsJndiName
public T applyNameAsJndiName(boolean isJndiName)
Description copied from interface:SessionFactoryBuilderApplies a SessionFactory name.- Specified by:
applyNameAsJndiNamein interfaceSessionFactoryBuilder- Parameters:
isJndiName-trueindicates that the name specified inSessionFactoryBuilder.applyName(java.lang.String)will be used for binding the SessionFactory into JNDI.- Returns:
this, for method chaining- See Also:
AvailableSettings.SESSION_FACTORY_NAME_IS_JNDI
-
applyAutoClosing
public T applyAutoClosing(boolean enabled)
Description copied from interface:SessionFactoryBuilderApplies whether Sessions should be automatically closed at the end of the transaction.- Specified by:
applyAutoClosingin interfaceSessionFactoryBuilder- Parameters:
enabled-trueindicates they should be auto-closed;falseindicates not.- Returns:
this, for method chaining- See Also:
AvailableSettings.AUTO_CLOSE_SESSION
-
applyAutoFlushing
public T applyAutoFlushing(boolean enabled)
Description copied from interface:SessionFactoryBuilderApplies whether Sessions should be automatically flushed at the end of the transaction.- Specified by:
applyAutoFlushingin interfaceSessionFactoryBuilder- Parameters:
enabled-trueindicates they should be auto-flushed;falseindicates not.- Returns:
this, for method chaining- See Also:
AvailableSettings.FLUSH_BEFORE_COMPLETION
-
applyStatisticsSupport
public T applyStatisticsSupport(boolean enabled)
Description copied from interface:SessionFactoryBuilderApplies whether statistics gathering is enabled.- Specified by:
applyStatisticsSupportin interfaceSessionFactoryBuilder- Parameters:
enabled-trueindicates that statistics gathering should be enabled;falseindicates not.- Returns:
this, for method chaining- See Also:
AvailableSettings.GENERATE_STATISTICS
-
applyInterceptor
public T applyInterceptor(Interceptor interceptor)
Description copied from interface:SessionFactoryBuilderNames an interceptor to be applied to the SessionFactory, which in turn means it will be used by all Sessions unless one is explicitly specified inSessionBuilder.interceptor(org.hibernate.Interceptor)- Specified by:
applyInterceptorin interfaceSessionFactoryBuilder- Parameters:
interceptor- The interceptor- Returns:
this, for method chaining- See Also:
AvailableSettings.INTERCEPTOR
-
applyStatementInspector
public T applyStatementInspector(StatementInspector statementInspector)
Description copied from interface:SessionFactoryBuilderNames a StatementInspector to be applied to the SessionFactory, which in turn means it will be used by all Sessions unless one is explicitly specified inSessionBuilder.statementInspector(org.hibernate.resource.jdbc.spi.StatementInspector)- Specified by:
applyStatementInspectorin interfaceSessionFactoryBuilder- Parameters:
statementInspector- The StatementInspector- Returns:
this, for method chaining- See Also:
AvailableSettings.STATEMENT_INSPECTOR
-
addSessionFactoryObservers
public T addSessionFactoryObservers(SessionFactoryObserver... observers)
Description copied from interface:SessionFactoryBuilderSpecifies one or more observers to be applied to the SessionFactory. Can be called multiple times to add additional observers.- Specified by:
addSessionFactoryObserversin interfaceSessionFactoryBuilder- Parameters:
observers- The observers to add- Returns:
this, for method chaining
-
applyCustomEntityDirtinessStrategy
public T applyCustomEntityDirtinessStrategy(CustomEntityDirtinessStrategy strategy)
Description copied from interface:SessionFactoryBuilderSpecifies a custom entity dirtiness strategy to be applied to the SessionFactory. See the contract ofCustomEntityDirtinessStrategyfor details.- Specified by:
applyCustomEntityDirtinessStrategyin interfaceSessionFactoryBuilder- Parameters:
strategy- The custom strategy to be used.- Returns:
this, for method chaining- See Also:
AvailableSettings.CUSTOM_ENTITY_DIRTINESS_STRATEGY
-
addEntityNameResolver
public T addEntityNameResolver(EntityNameResolver... entityNameResolvers)
Description copied from interface:SessionFactoryBuilderSpecifies one or more entity name resolvers to be applied to the SessionFactory (see theEntityNameResolvercontract for more information.. Can be called multiple times to add additional resolvers..- Specified by:
addEntityNameResolverin interfaceSessionFactoryBuilder- Parameters:
entityNameResolvers- The entityNameResolvers to add- Returns:
this, for method chaining
-
applyEntityNotFoundDelegate
public T applyEntityNotFoundDelegate(EntityNotFoundDelegate entityNotFoundDelegate)
Description copied from interface:SessionFactoryBuilderNames theEntityNotFoundDelegateto be applied to the SessionFactory. EntityNotFoundDelegate is a strategy that accounts for different exceptions thrown between Hibernate and JPA when an entity cannot be found.- Specified by:
applyEntityNotFoundDelegatein interfaceSessionFactoryBuilder- Parameters:
entityNotFoundDelegate- The delegate/strategy to use.- Returns:
this, for method chaining
-
applyIdentifierRollbackSupport
public T applyIdentifierRollbackSupport(boolean enabled)
Description copied from interface:SessionFactoryBuilderShould generated identifiers be "unset" on entities during a rollback?- Specified by:
applyIdentifierRollbackSupportin interfaceSessionFactoryBuilder- Parameters:
enabled-trueindicates identifiers should be unset;falseindicates not.- Returns:
this, for method chaining- See Also:
AvailableSettings.USE_IDENTIFIER_ROLLBACK
-
applyDefaultEntityMode
public T applyDefaultEntityMode(EntityMode entityMode)
Description copied from interface:SessionFactoryBuilderApplies the given entity mode as the default for the SessionFactory.- Specified by:
applyDefaultEntityModein interfaceSessionFactoryBuilder- Parameters:
entityMode- The default entity mode to use.- Returns:
this, for method chaining- See Also:
AvailableSettings.DEFAULT_ENTITY_MODE
-
applyNullabilityChecking
public T applyNullabilityChecking(boolean enabled)
Description copied from interface:SessionFactoryBuilderShould attributes using columns marked as not-null be checked (by Hibernate) for nullness?- Specified by:
applyNullabilityCheckingin interfaceSessionFactoryBuilder- Parameters:
enabled-trueindicates that Hibernate should perform nullness checking;falseindicates it should not.- Returns:
this, for method chaining- See Also:
AvailableSettings.CHECK_NULLABILITY
-
applyLazyInitializationOutsideTransaction
public T applyLazyInitializationOutsideTransaction(boolean enabled)
Description copied from interface:SessionFactoryBuilderShould the application be allowed to initialize uninitialized lazy state outside the bounds of a transaction?- Specified by:
applyLazyInitializationOutsideTransactionin interfaceSessionFactoryBuilder- Parameters:
enabled-trueindicates initialization outside the transaction should be allowed;falseindicates it should not.- Returns:
this, for method chaining- See Also:
AvailableSettings.ENABLE_LAZY_LOAD_NO_TRANS
-
applyEntityTuplizerFactory
public T applyEntityTuplizerFactory(EntityTuplizerFactory entityTuplizerFactory)
Description copied from interface:SessionFactoryBuilderSpecify the EntityTuplizerFactory to use.- Specified by:
applyEntityTuplizerFactoryin interfaceSessionFactoryBuilder- Parameters:
entityTuplizerFactory- The EntityTuplizerFactory to use.- Returns:
this, for method chaining
-
applyEntityTuplizer
public T applyEntityTuplizer(EntityMode entityMode, java.lang.Class<? extends EntityTuplizer> tuplizerClass)
Description copied from interface:SessionFactoryBuilderRegister the defaultEntityTuplizerto be applied to the SessionFactory.- Specified by:
applyEntityTuplizerin interfaceSessionFactoryBuilder- Parameters:
entityMode- The entity mode that which this tuplizer will be applied.tuplizerClass- The custom tuplizer class.- Returns:
this, for method chaining
-
applyMultiTableBulkIdStrategy
public T applyMultiTableBulkIdStrategy(MultiTableBulkIdStrategy strategy)
Description copied from interface:SessionFactoryBuilderHow should updates and deletes that span multiple tables be handled?- Specified by:
applyMultiTableBulkIdStrategyin interfaceSessionFactoryBuilder- Parameters:
strategy- The strategy for handling multi-table updates and deletes.- Returns:
this, for method chaining- See Also:
AvailableSettings.HQL_BULK_ID_STRATEGY
-
applyTempTableDdlTransactionHandling
public T applyTempTableDdlTransactionHandling(TempTableDdlTransactionHandling handling)
- Specified by:
applyTempTableDdlTransactionHandlingin interfaceSessionFactoryBuilder
-
applyBatchFetchStyle
public T applyBatchFetchStyle(BatchFetchStyle style)
Description copied from interface:SessionFactoryBuilderWhat style of batching should be used?- Specified by:
applyBatchFetchStylein interfaceSessionFactoryBuilder- Parameters:
style- The style to use- Returns:
this, for method chaining- See Also:
AvailableSettings.BATCH_FETCH_STYLE
-
applyDelayedEntityLoaderCreations
public SessionFactoryBuilder applyDelayedEntityLoaderCreations(boolean delay)
Description copied from interface:SessionFactoryBuilderShould entity Loaders be generated immediately? Or should the creation be delayed until first need?- Specified by:
applyDelayedEntityLoaderCreationsin interfaceSessionFactoryBuilder- See Also:
AvailableSettings.DELAY_ENTITY_LOADER_CREATIONS
-
applyDefaultBatchFetchSize
public T applyDefaultBatchFetchSize(int size)
Description copied from interface:SessionFactoryBuilderAllows specifying a default batch-fetch size for all entities and collections which do not otherwise specify a batch-fetch size.- Specified by:
applyDefaultBatchFetchSizein interfaceSessionFactoryBuilder- Parameters:
size- The size to use for batch fetching for entities/collections which do not specify an explicit batch fetch size.- Returns:
this, for method chaining- See Also:
AvailableSettings.DEFAULT_BATCH_FETCH_SIZE
-
applyMaximumFetchDepth
public T applyMaximumFetchDepth(int depth)
Description copied from interface:SessionFactoryBuilderApply a limit to the depth Hibernate will use for outer joins. Note that this is different than an overall limit on the number of joins...- Specified by:
applyMaximumFetchDepthin interfaceSessionFactoryBuilder- Parameters:
depth- The depth for limiting joins.- Returns:
this, for method chaining- See Also:
AvailableSettings.MAX_FETCH_DEPTH
-
applyDefaultNullPrecedence
public T applyDefaultNullPrecedence(NullPrecedence nullPrecedence)
Description copied from interface:SessionFactoryBuilderApply a null precedence (NULLS FIRST, NULLS LAST) to be applied order-by clauses rendered into SQL queries.- Specified by:
applyDefaultNullPrecedencein interfaceSessionFactoryBuilder- Parameters:
nullPrecedence- The default null precedence to use.- Returns:
this, for method chaining- See Also:
AvailableSettings.DEFAULT_NULL_ORDERING
-
applyOrderingOfInserts
public T applyOrderingOfInserts(boolean enabled)
Description copied from interface:SessionFactoryBuilderApply whether ordering of inserts should be enabled. This allows more efficient SQL generation via the use of batching for the inserts; the cost is that the determination of the ordering is far more inefficient than not ordering.- Specified by:
applyOrderingOfInsertsin interfaceSessionFactoryBuilder- Parameters:
enabled-trueindicates that ordering should be enabled;falseindicates not- Returns:
this, for method chaining- See Also:
AvailableSettings.ORDER_INSERTS
-
applyOrderingOfUpdates
public T applyOrderingOfUpdates(boolean enabled)
Description copied from interface:SessionFactoryBuilderApply whether ordering of updates should be enabled. This allows more efficient SQL generation via the use of batching for the updates; the cost is that the determination of the ordering is far more inefficient than not ordering.- Specified by:
applyOrderingOfUpdatesin interfaceSessionFactoryBuilder- Parameters:
enabled-trueindicates that ordering should be enabled;falseindicates not- Returns:
this, for method chaining- See Also:
AvailableSettings.ORDER_UPDATES
-
applyMultiTenancyStrategy
public T applyMultiTenancyStrategy(MultiTenancyStrategy strategy)
Description copied from interface:SessionFactoryBuilderApply the form of multi-tenancy used by the application- Specified by:
applyMultiTenancyStrategyin interfaceSessionFactoryBuilder- Parameters:
strategy- The form of multi-tenancy in use.- Returns:
this, for method chaining- See Also:
AvailableSettings.MULTI_TENANT
-
applyCurrentTenantIdentifierResolver
public T applyCurrentTenantIdentifierResolver(CurrentTenantIdentifierResolver resolver)
Description copied from interface:SessionFactoryBuilderSpecifies a strategy for resolving the notion of a "current" tenant-identifier when using multi-tenancy together with current sessions- Specified by:
applyCurrentTenantIdentifierResolverin interfaceSessionFactoryBuilder- Parameters:
resolver- The resolution strategy to use.- Returns:
this, for method chaining- See Also:
AvailableSettings.MULTI_TENANT_IDENTIFIER_RESOLVER
-
applyJtaTrackingByThread
public T applyJtaTrackingByThread(boolean enabled)
Description copied from interface:SessionFactoryBuilderIf using the built-in Hibernate JTA-based TransactionCoordinator/Builder, should it track JTA transactions by thread in an attempt to detect timeouts?- Specified by:
applyJtaTrackingByThreadin interfaceSessionFactoryBuilder- Parameters:
enabled-trueindicates we should track by thread;falseindicates not- Returns:
this, for method chaining- See Also:
AvailableSettings.JTA_TRACK_BY_THREAD
-
applyPreferUserTransactions
public T applyPreferUserTransactions(boolean preferUserTransactions)
Description copied from interface:SessionFactoryBuilderIf using the built-in Hibernate JTA-based TransactionCoordinator/Builder, should it prefer to useUserTransactionoverTransaction?- Specified by:
applyPreferUserTransactionsin interfaceSessionFactoryBuilder- Parameters:
preferUserTransactions-trueindicates we should preferUserTransaction;falseindicates we should preferTransaction- Returns:
this, for method chaining- See Also:
AvailableSettings.PREFER_USER_TRANSACTION
-
applyQuerySubstitutions
public T applyQuerySubstitutions(java.util.Map substitutions)
Description copied from interface:SessionFactoryBuilderApply query substitutions to use in HQL queries. Note, this is a legacy feature and almost always never needed anymore...- Specified by:
applyQuerySubstitutionsin interfaceSessionFactoryBuilder- Parameters:
substitutions- The substitution map- Returns:
this, for method chaining- See Also:
AvailableSettings.QUERY_SUBSTITUTIONS
-
applyStrictJpaQueryLanguageCompliance
public T applyStrictJpaQueryLanguageCompliance(boolean enabled)
Description copied from interface:SessionFactoryBuilderShould we strictly adhere to JPA Query Language (JPQL) syntax, or more broadly support all of Hibernate's superset (HQL)? Setting this totruemay cause valid HQL to throw an exception because it violates the JPQL subset.- Specified by:
applyStrictJpaQueryLanguageCompliancein interfaceSessionFactoryBuilder- Parameters:
enabled-trueindicates that we should strictly adhere to the JPQL subset;falseindicates we should accept the broader HQL syntax.- Returns:
this, for method chaining- See Also:
AvailableSettings.JPAQL_STRICT_COMPLIANCE
-
applyNamedQueryCheckingOnStartup
public T applyNamedQueryCheckingOnStartup(boolean enabled)
Description copied from interface:SessionFactoryBuilderShould named queries be checked on startup?- Specified by:
applyNamedQueryCheckingOnStartupin interfaceSessionFactoryBuilder- Parameters:
enabled-trueindicates that they should;falseindicates they should not.- Returns:
this, for method chaining- See Also:
AvailableSettings.QUERY_STARTUP_CHECKING
-
applySecondLevelCacheSupport
public T applySecondLevelCacheSupport(boolean enabled)
Description copied from interface:SessionFactoryBuilderShould second level caching support be enabled?- Specified by:
applySecondLevelCacheSupportin interfaceSessionFactoryBuilder- Parameters:
enabled-trueindicates we should enable the use of second level caching;falseindicates we should disable the use of second level caching.- Returns:
this, for method chaining- See Also:
AvailableSettings.USE_SECOND_LEVEL_CACHE
-
applyQueryCacheSupport
public T applyQueryCacheSupport(boolean enabled)
Description copied from interface:SessionFactoryBuilderShould second level query caching support be enabled?- Specified by:
applyQueryCacheSupportin interfaceSessionFactoryBuilder- Parameters:
enabled-trueindicates we should enable the use of second level query caching;falseindicates we should disable the use of second level query caching.- Returns:
this, for method chaining- See Also:
AvailableSettings.USE_QUERY_CACHE
-
applyTimestampsCacheFactory
public SessionFactoryBuilder applyTimestampsCacheFactory(TimestampsCacheFactory factory)
Description copied from interface:SessionFactoryBuilderSpecifies a QueryCacheFactory to use for building query cache handlers.- Specified by:
applyTimestampsCacheFactoryin interfaceSessionFactoryBuilder- Parameters:
factory- The QueryCacheFactory to use- Returns:
this, for method chaining- See Also:
AvailableSettings.QUERY_CACHE_FACTORY
-
applyCacheRegionPrefix
public T applyCacheRegionPrefix(java.lang.String prefix)
Description copied from interface:SessionFactoryBuilderApply a prefix to prepended to all cache region names for this SessionFactory.- Specified by:
applyCacheRegionPrefixin interfaceSessionFactoryBuilder- Parameters:
prefix- The prefix.- Returns:
this, for method chaining- See Also:
AvailableSettings.CACHE_REGION_PREFIX
-
applyMinimalPutsForCaching
public T applyMinimalPutsForCaching(boolean enabled)
Description copied from interface:SessionFactoryBuilderBy default, Hibernate will always just push data into the cache without first checking if that data already exists. For some caches (mainly distributed caches) this can have a major adverse performance impact. For these caches, it is best to enable this "minimal puts" feature. Cache integrations also report whether "minimal puts" should be enabled by default. So its is very rare that users need to set this, generally speaking.- Specified by:
applyMinimalPutsForCachingin interfaceSessionFactoryBuilder- Parameters:
enabled-trueindicates Hibernate should first check whether data exists and only push to the cache if it does not already exist.falseindicates to perform the default behavior.- Returns:
this, for method chaining- See Also:
AvailableSettings.USE_MINIMAL_PUTS,RegionFactory.isMinimalPutsEnabledByDefault()
-
applyStructuredCacheEntries
public T applyStructuredCacheEntries(boolean enabled)
Description copied from interface:SessionFactoryBuilderBy default, Hibernate stores data in the cache in its own optimized format. However, that format is impossible to "read" if browsing the cache. The use of "structured" cache entries allows the cached data to be read.- Specified by:
applyStructuredCacheEntriesin interfaceSessionFactoryBuilder- Parameters:
enabled-trueindicates that structured cache entries (human readable) should be used;falseindicates that the native entry structure should be used.- Returns:
this, for method chaining- See Also:
AvailableSettings.USE_STRUCTURED_CACHE
-
applyDirectReferenceCaching
public T applyDirectReferenceCaching(boolean enabled)
Description copied from interface:SessionFactoryBuilderGenerally, Hibernate will extract the information from an entity and put that extracted information into the second-level cache. This is by far the safest way to second-level cache persistent data. However, there are some cases where it is safe to cache the entity instance directly. This setting controls whether that is used in those cases.- Specified by:
applyDirectReferenceCachingin interfaceSessionFactoryBuilder- Parameters:
enabled-trueindicates that applicable entities will be stored into the second-level cache directly by reference; false indicates that all entities will be stored via the extraction approach.- Returns:
this, for method chaining- See Also:
AvailableSettings.USE_DIRECT_REFERENCE_CACHE_ENTRIES
-
applyAutomaticEvictionOfCollectionCaches
public T applyAutomaticEvictionOfCollectionCaches(boolean enabled)
Description copied from interface:SessionFactoryBuilderWhen using bi-directional many-to-one associations and caching the one-to-many side it is expected that both sides of the association are managed (actually that is true of all bi-directional associations). However, in this case, if the user forgets to manage the one-to-many side stale data can be left in the second-level cache. Warning: enabling this will have a performance impact. Hence why it is disabled by default (for good citizens) and is an opt-in setting.- Specified by:
applyAutomaticEvictionOfCollectionCachesin interfaceSessionFactoryBuilder- Parameters:
enabled-trueindicates that these collection caches should be evicted automatically.- Returns:
this, for method chaining- See Also:
AvailableSettings.AUTO_EVICT_COLLECTION_CACHE
-
applyJdbcBatchSize
public T applyJdbcBatchSize(int size)
Description copied from interface:SessionFactoryBuilderSpecifies the maximum number of statements to batch together in a JDBC batch for insert, update and delete operations. A non-zero number enables batching, but really only a number greater than zero will have any effect. If used, a number great than 5 is suggested.- Specified by:
applyJdbcBatchSizein interfaceSessionFactoryBuilder- Parameters:
size- The batch size to use.- Returns:
this, for method chaining- See Also:
AvailableSettings.STATEMENT_BATCH_SIZE
-
applyJdbcBatchingForVersionedEntities
public T applyJdbcBatchingForVersionedEntities(boolean enabled)
Description copied from interface:SessionFactoryBuilderThis setting controls whether versioned entities will be included in JDBC batching. The reason being that some JDBC drivers have a problems returning "accurate" update counts from batch statements. This is setting isfalseby default.- Specified by:
applyJdbcBatchingForVersionedEntitiesin interfaceSessionFactoryBuilder- Parameters:
enabled- The batch size to use.- Returns:
this, for method chaining- See Also:
AvailableSettings.BATCH_VERSIONED_DATA
-
applyScrollableResultsSupport
public T applyScrollableResultsSupport(boolean enabled)
Description copied from interface:SessionFactoryBuilderShould scrollable results be supported in queries? We ask the JDBC driver whether it supports scrollable result sets as the default for this setting, but some drivers do not accurately report this via DatabaseMetaData. Also, needed if user is supplying connections (and so no Connection is available when we bootstrap).- Specified by:
applyScrollableResultsSupportin interfaceSessionFactoryBuilder- Parameters:
enabled-trueto enable this support,falseto disable it- Returns:
this, for method chaining- See Also:
AvailableSettings.USE_SCROLLABLE_RESULTSET
-
applyResultSetsWrapping
public T applyResultSetsWrapping(boolean enabled)
Description copied from interface:SessionFactoryBuilderHibernate currently accesses results from the JDBC ResultSet by name. This is known to be VERY slow on some drivers, especially older Oracle drivers. This setting allows Hibernate to wrap the ResultSet of the JDBC driver to manage the name->position resolution itself.- Specified by:
applyResultSetsWrappingin interfaceSessionFactoryBuilder- Parameters:
enabled-trueindicates Hibernate should wrap result sets;falseindicates it should not.- Returns:
this, for method chaining- See Also:
AvailableSettings.WRAP_RESULT_SETS
-
applyGetGeneratedKeysSupport
public T applyGetGeneratedKeysSupport(boolean enabled)
Description copied from interface:SessionFactoryBuilderShould JDBCStatement.getGeneratedKeys()feature be used for retrieval of *insert-generated* ids?- Specified by:
applyGetGeneratedKeysSupportin interfaceSessionFactoryBuilder- Parameters:
enabled-trueindicates we should use JDBC getGeneratedKeys support;falseindicates we should not.- Returns:
this, for method chaining- See Also:
AvailableSettings.USE_GET_GENERATED_KEYS
-
applyJdbcFetchSize
public T applyJdbcFetchSize(int size)
Description copied from interface:SessionFactoryBuilderApply a fetch size to the JDBC driver for fetching results.- Specified by:
applyJdbcFetchSizein interfaceSessionFactoryBuilder- Parameters:
size- The fetch size to be passed to the driver.- Returns:
this, for method chaining- See Also:
AvailableSettings.USE_GET_GENERATED_KEYS,Statement.setFetchSize(int)
-
applyConnectionReleaseMode
public T applyConnectionReleaseMode(ConnectionReleaseMode connectionReleaseMode)
Description copied from interface:SessionFactoryBuilderApply a ConnectionReleaseMode.- Specified by:
applyConnectionReleaseModein interfaceSessionFactoryBuilder- Parameters:
connectionReleaseMode- The ConnectionReleaseMode to use.- Returns:
this, for method chaining- See Also:
AvailableSettings.RELEASE_CONNECTIONS
-
applyConnectionProviderDisablesAutoCommit
public SessionFactoryBuilder applyConnectionProviderDisablesAutoCommit(boolean providerDisablesAutoCommit)
- Specified by:
applyConnectionProviderDisablesAutoCommitin interfaceSessionFactoryBuilder- See Also:
AvailableSettings.CONNECTION_PROVIDER_DISABLES_AUTOCOMMIT
-
applySqlComments
public T applySqlComments(boolean enabled)
Description copied from interface:SessionFactoryBuilderShould Hibernate apply comments to SQL it generates?- Specified by:
applySqlCommentsin interfaceSessionFactoryBuilder- Parameters:
enabled-trueindicates comments should be applied;falseindicates not.- Returns:
this, for method chaining- See Also:
AvailableSettings.USE_SQL_COMMENTS
-
applySqlFunction
public T applySqlFunction(java.lang.String registrationName, SQLFunction sqlFunction)
Description copied from interface:SessionFactoryBuilderApply a SQLFunction to the underlyingSQLFunctionRegistry. TODO : Ultimately I would like this to move toMetadataBuilderin conjunction with allowing mappings to reference SQLFunctions. today mappings can only name SQL functions directly, not through the SQLFunctionRegistry indirection- Specified by:
applySqlFunctionin interfaceSessionFactoryBuilder- Parameters:
registrationName- The name to register it under.sqlFunction- The SQLFunction impl- Returns:
this, for method chaining
-
allowOutOfTransactionUpdateOperations
public T allowOutOfTransactionUpdateOperations(boolean allow)
- Specified by:
allowOutOfTransactionUpdateOperationsin interfaceSessionFactoryBuilder
-
enableReleaseResourcesOnCloseEnabled
public T enableReleaseResourcesOnCloseEnabled(boolean enable)
Description copied from interface:SessionFactoryBuilderShould resources held byEntityManagerinstance be released immediately on close? The other option is to release them as part of an after-transaction callback.- Specified by:
enableReleaseResourcesOnCloseEnabledin interfaceSessionFactoryBuilder
-
enableJpaQueryCompliance
public SessionFactoryBuilder enableJpaQueryCompliance(boolean enabled)
- Specified by:
enableJpaQueryCompliancein interfaceSessionFactoryBuilder- See Also:
JpaCompliance.isJpaQueryComplianceEnabled()
-
enableJpaTransactionCompliance
public SessionFactoryBuilder enableJpaTransactionCompliance(boolean enabled)
- Specified by:
enableJpaTransactionCompliancein interfaceSessionFactoryBuilder- See Also:
JpaCompliance.isJpaTransactionComplianceEnabled()
-
enableJpaListCompliance
public SessionFactoryBuilder enableJpaListCompliance(boolean enabled)
- Specified by:
enableJpaListCompliancein interfaceSessionFactoryBuilder- See Also:
JpaCompliance.isJpaListComplianceEnabled()
-
enableJpaClosedCompliance
public SessionFactoryBuilder enableJpaClosedCompliance(boolean enabled)
- Specified by:
enableJpaClosedCompliancein interfaceSessionFactoryBuilder- See Also:
JpaCompliance.isJpaClosedComplianceEnabled()
-
unwrap
public <S extends SessionFactoryBuilder> S unwrap(java.lang.Class<S> type)
Description copied from interface:SessionFactoryBuilderAllows unwrapping this builder as another, more specific type.- Specified by:
unwrapin interfaceSessionFactoryBuilder- Returns:
- The unwrapped builder.
-
applyStatelessInterceptor
public T applyStatelessInterceptor(java.util.function.Supplier<? extends Interceptor> statelessInterceptorSupplier)
Description copied from interface:SessionFactoryBuilderNames aSupplierinstance which is used to retrieve the interceptor to be applied to the SessionFactory, which in turn means it will be used by all Sessions unless one is explicitly specified inSessionBuilder.interceptor(org.hibernate.Interceptor)- Specified by:
applyStatelessInterceptorin interfaceSessionFactoryBuilder- Parameters:
statelessInterceptorSupplier-Supplierinstance which is used to retrieve the interceptor- Returns:
this, for method chaining- See Also:
AvailableSettings.SESSION_SCOPED_INTERCEPTOR
-
applyStatelessInterceptor
public T applyStatelessInterceptor(java.lang.Class<? extends Interceptor> statelessInterceptorClass)
Description copied from interface:SessionFactoryBuilderNames an interceptor Class to be applied to the SessionFactory, which in turn means it will be used by all Sessions unless one is explicitly specified inSessionBuilder.interceptor(org.hibernate.Interceptor)- Specified by:
applyStatelessInterceptorin interfaceSessionFactoryBuilder- Parameters:
statelessInterceptorClass- The interceptor class- Returns:
this, for method chaining- See Also:
AvailableSettings.SESSION_SCOPED_INTERCEPTOR
-
applyConnectionHandlingMode
public T applyConnectionHandlingMode(PhysicalConnectionHandlingMode connectionHandlingMode)
Description copied from interface:SessionFactoryBuilderApply the specified handling mode for JDBC connections- Specified by:
applyConnectionHandlingModein interfaceSessionFactoryBuilder- Parameters:
connectionHandlingMode- The handling mode to apply- Returns:
this, for method chaining- See Also:
AvailableSettings.ACQUIRE_CONNECTIONS,AvailableSettings.RELEASE_CONNECTIONS,ConnectionAcquisitionMode,ConnectionReleaseMode
-
build
public SessionFactory build()
Description copied from interface:SessionFactoryBuilderAfter all options have been set, build the SessionFactory.- Specified by:
buildin interfaceSessionFactoryBuilder- Returns:
- The built SessionFactory.
-
-