Class AbstractDelegatingSessionFactoryBuilder<T extends SessionFactoryBuilder>
- java.lang.Object
-
- org.hibernate.boot.spi.AbstractDelegatingSessionFactoryBuilder<T>
-
- Type Parameters:
T
- The specific subclass; Allows subclasses to narrow the return type of the contract methods to a specialization ofMetadataBuilderImplementor
.
- All Implemented Interfaces:
SessionFactoryBuilder
- Direct Known Subclasses:
AbstractDelegatingSessionFactoryBuilderImplementor
public abstract class AbstractDelegatingSessionFactoryBuilder<T extends SessionFactoryBuilder> extends 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 T
addEntityNameResolver(EntityNameResolver... entityNameResolvers)
Specifies one or more entity name resolvers.T
addSessionFactoryObservers(SessionFactoryObserver... observers)
Specifies one or more observers.T
allowOutOfTransactionUpdateOperations(boolean allow)
T
applyAutoClosing(boolean enabled)
Specifies whetherSession
s should be automatically closed at the end of the transaction.T
applyAutoFlushing(boolean enabled)
Applies whetherSession
s should be automatically flushed at the end of the transaction.T
applyAutomaticEvictionOfCollectionCaches(boolean enabled)
When using bidirectional 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 bidirectional associations).T
applyBatchFetchStyle(BatchFetchStyle style)
What style of batching should be used?T
applyBeanManager(Object beanManager)
Specifies a CDIBeanManager
.T
applyCacheRegionPrefix(String prefix)
Specify a prefix to prepended to all cache region names.SessionFactoryBuilder
applyCollectionsInDefaultFetchGroup(boolean enabled)
Should collections be included in the default fetch group when bytecode enhancement is used?T
applyConnectionHandlingMode(PhysicalConnectionHandlingMode connectionHandlingMode)
Specifies the connection handling mode for JDBC connections.SessionFactoryBuilder
applyConnectionProviderDisablesAutoCommit(boolean providerDisablesAutoCommit)
T
applyCurrentTenantIdentifierResolver(CurrentTenantIdentifierResolver<?> resolver)
Specifies aCurrentTenantIdentifierResolver
that is responsible for resolving the current tenant identifier.T
applyCustomEntityDirtinessStrategy(CustomEntityDirtinessStrategy strategy)
Specifies aCustomEntityDirtinessStrategy
.T
applyDefaultBatchFetchSize(int size)
Specifies a default batch fetch size for all entities and collections which do not otherwise specify a batch fetch size.T
applyDefaultNullPrecedence(NullPrecedence nullPrecedence)
Apply a null precedence,NULLS FIRST
orNULLS LAST
, toorder by
clauses rendered in SQL queries.SessionFactoryBuilder
applyDelayedEntityLoaderCreations(boolean delay)
Should entity loaders be generated immediately? Or should the creation be delayed until first need?T
applyDirectReferenceCaching(boolean enabled)
Generally, Hibernate will extract the information from an entity and put that extracted information into the second-level cache.T
applyEntityNotFoundDelegate(EntityNotFoundDelegate entityNotFoundDelegate)
Specifies anEntityNotFoundDelegate
.T
applyGetGeneratedKeysSupport(boolean enabled)
Should JDBCStatement.getGeneratedKeys()
feature be used for retrieval of *insert-generated* ids?T
applyIdentifierRollbackSupport(boolean enabled)
Should the generated identifier be "unset" when an entity is deleted?T
applyInterceptor(Interceptor interceptor)
Specifies anInterceptor
associated with theSessionFactory
, which will be used by all sessions unless an interceptor is explicitly specified usingSessionBuilder.interceptor(org.hibernate.Interceptor)
.T
applyJdbcBatchingForVersionedEntities(boolean enabled)
This setting controls whether versioned entities will be included in JDBC batching.T
applyJdbcBatchSize(int size)
Specifies the maximum number of statements to batch together in a JDBC batch for insert, update and delete operations.T
applyJdbcFetchSize(int size)
Apply a fetch size to the JDBC driver for fetching results.SessionFactoryBuilder
applyJsonFormatMapper(FormatMapper jsonFormatMapper)
Specifies aformat mapper
to use for serialization/deserialization of JSON properties.T
applyJtaTrackingByThread(boolean enabled)
If using the built-in JTA-basedTransactionCoordinator
orTransactionCoordinatorBuilder
, should it track JTA transactions by thread in an attempt to detect timeouts?T
applyLazyInitializationOutsideTransaction(boolean enabled)
Should the application be allowed to initialize uninitialized lazy state outside the bounds of a transaction?T
applyMaximumFetchDepth(int depth)
Apply a limit to the depth Hibernate will use for outer joins.T
applyMinimalPutsForCaching(boolean enabled)
By default, Hibernate will always just push data into the cache without first checking if that data already exists.T
applyMultiTenancy(boolean enabled)
Specifies whether multi-tenancy is enabledT
applyName(String sessionFactoryName)
Specifies a name for theSessionFactory
.T
applyNameAsJndiName(boolean isJndiName)
Specifies that theSessionFactory
should be registered in JNDI, under the name specified usingSessionFactoryBuilder.applyName(String)
.T
applyNamedQueryCheckingOnStartup(boolean enabled)
Should named queries be checked on startup?T
applyNullabilityChecking(boolean enabled)
Should attributes using columns marked as not-null be checked (by Hibernate) for nullness, or should this be left as a job for the database?T
applyOrderingOfInserts(boolean enabled)
Specify whether ordering of inserts should be enabled.T
applyOrderingOfUpdates(boolean enabled)
Specify whether ordering of updates should be enabled.T
applyPreferUserTransactions(boolean preferUserTransactions)
If using the built-in JTA-basedTransactionCoordinator
orTransactionCoordinatorBuilder
, should it prefer to useUserTransaction
in preference toTransaction
?SessionFactoryBuilder
applyQueryCacheLayout(CacheLayout cacheLayout)
Specifies the defaultCacheLayout
to use for query cache entries.T
applyQueryCacheSupport(boolean enabled)
Should second level query caching support be enabled?T
applyScrollableResultsSupport(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.T
applySecondLevelCacheSupport(boolean enabled)
Should second level caching support be enabled?T
applySqlComments(boolean enabled)
Should Hibernate apply comments to SQL it generates?T
applySqlFunction(String registrationName, SqmFunctionDescriptor sqlFunction)
Register aSQL function
with the underlyingSqmFunctionRegistry
.T
applyStatelessInterceptor(Class<? extends Interceptor> statelessInterceptorClass)
Specifies an interceptorClass
associated with theSessionFactory
, which is used to instantiate a new interceptor for each session, unless an interceptor is explicitly specified usingSessionBuilder.interceptor(org.hibernate.Interceptor)
.T
applyStatelessInterceptor(Supplier<? extends Interceptor> statelessInterceptorSupplier)
Specifies an interceptorSupplier
associated with theSessionFactory
, which is used to obtain an interceptor for each session, unless an interceptor is explicitly specified usingSessionBuilder.interceptor(org.hibernate.Interceptor)
.T
applyStatementInspector(StatementInspector statementInspector)
Specifies aStatementInspector
associated with theSessionFactory
, which will be used by all sessions unless a statement inspector is explicitly specified usingSessionBuilder.statementInspector(org.hibernate.resource.jdbc.spi.StatementInspector)
T
applyStatisticsSupport(boolean enabled)
Specifies whether statistics gathering is enabled.T
applyStructuredCacheEntries(boolean enabled)
By default, Hibernate stores data in the cache in its own optimized format.SessionFactoryBuilder
applySubselectFetchEnabled(boolean enabled)
Enable the use of subselect fetching.T
applyTempTableDdlTransactionHandling(TempTableDdlTransactionHandling handling)
SessionFactoryBuilder
applyTimestampsCacheFactory(TimestampsCacheFactory factory)
Specifies aTimestampsCacheFactory
.T
applyValidatorFactory(Object validatorFactory)
Specifies a Bean ValidationValidatorFactory
.SessionFactoryBuilder
applyXmlFormatMapper(FormatMapper xmlFormatMapper)
Specifies aformat mapper
to use for serialization/deserialization of XML properties.SessionFactory
build()
After all options have been set, build the SessionFactory.protected SessionFactoryBuilder
delegate()
SessionFactoryBuilder
enableJpaClosedCompliance(boolean enabled)
SessionFactoryBuilder
enableJpaListCompliance(boolean enabled)
SessionFactoryBuilder
enableJpaOrderByMappingCompliance(boolean enabled)
SessionFactoryBuilder
enableJpaQueryCompliance(boolean enabled)
SessionFactoryBuilder
enableJpaTransactionCompliance(boolean enabled)
T
enableReleaseResourcesOnCloseEnabled(boolean enable)
Should resources held by anEntityManager
be released immediately on close?protected abstract T
getThis()
Returns a specific implementation.
-
-
-
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(Object validatorFactory)
Description copied from interface:SessionFactoryBuilder
Specifies a Bean ValidationValidatorFactory
.- Specified by:
applyValidatorFactory
in interfaceSessionFactoryBuilder
- Parameters:
validatorFactory
- The Bean ValidationValidatorFactory
to use- Returns:
this
, for method chaining- See Also:
ValidationSettings.JAKARTA_VALIDATION_FACTORY
-
applyBeanManager
public T applyBeanManager(Object beanManager)
Description copied from interface:SessionFactoryBuilder
Specifies a CDIBeanManager
.- Specified by:
applyBeanManager
in interfaceSessionFactoryBuilder
- Parameters:
beanManager
- The CDIBeanManager
to use- Returns:
this
, for method chaining- See Also:
ManagedBeanSettings.JAKARTA_CDI_BEAN_MANAGER
-
applyName
public T applyName(String sessionFactoryName)
Description copied from interface:SessionFactoryBuilder
Specifies a name for theSessionFactory
.- Specified by:
applyName
in interfaceSessionFactoryBuilder
- Parameters:
sessionFactoryName
- The name to use- Returns:
this
, for method chaining- See Also:
PersistenceSettings.SESSION_FACTORY_NAME
-
applyNameAsJndiName
public T applyNameAsJndiName(boolean isJndiName)
Description copied from interface:SessionFactoryBuilder
Specifies that theSessionFactory
should be registered in JNDI, under the name specified usingSessionFactoryBuilder.applyName(String)
.- Specified by:
applyNameAsJndiName
in interfaceSessionFactoryBuilder
- Parameters:
isJndiName
-true
indicates 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:
PersistenceSettings.SESSION_FACTORY_NAME_IS_JNDI
-
applyAutoClosing
public T applyAutoClosing(boolean enabled)
Description copied from interface:SessionFactoryBuilder
Specifies whetherSession
s should be automatically closed at the end of the transaction.- Specified by:
applyAutoClosing
in interfaceSessionFactoryBuilder
- Parameters:
enabled
-true
indicates they should be auto-closed;false
indicates not.- Returns:
this
, for method chaining- See Also:
TransactionSettings.AUTO_CLOSE_SESSION
-
applyAutoFlushing
public T applyAutoFlushing(boolean enabled)
Description copied from interface:SessionFactoryBuilder
Applies whetherSession
s should be automatically flushed at the end of the transaction.- Specified by:
applyAutoFlushing
in interfaceSessionFactoryBuilder
- Parameters:
enabled
-true
indicates they should be auto-flushed;false
indicates not.- Returns:
this
, for method chaining- See Also:
TransactionSettings.FLUSH_BEFORE_COMPLETION
-
applyStatisticsSupport
public T applyStatisticsSupport(boolean enabled)
Description copied from interface:SessionFactoryBuilder
Specifies whether statistics gathering is enabled.- Specified by:
applyStatisticsSupport
in interfaceSessionFactoryBuilder
- Parameters:
enabled
-true
indicates that statistics gathering should be enabled;false
indicates not.- Returns:
this
, for method chaining- See Also:
StatisticsSettings.GENERATE_STATISTICS
-
applyInterceptor
public T applyInterceptor(Interceptor interceptor)
Description copied from interface:SessionFactoryBuilder
Specifies anInterceptor
associated with theSessionFactory
, which will be used by all sessions unless an interceptor is explicitly specified usingSessionBuilder.interceptor(org.hibernate.Interceptor)
.- Specified by:
applyInterceptor
in interfaceSessionFactoryBuilder
- Parameters:
interceptor
- The interceptor- Returns:
this
, for method chaining- See Also:
SessionEventSettings.INTERCEPTOR
-
applyStatementInspector
public T applyStatementInspector(StatementInspector statementInspector)
Description copied from interface:SessionFactoryBuilder
Specifies aStatementInspector
associated with theSessionFactory
, which will be used by all sessions unless a statement inspector is explicitly specified usingSessionBuilder.statementInspector(org.hibernate.resource.jdbc.spi.StatementInspector)
- Specified by:
applyStatementInspector
in interfaceSessionFactoryBuilder
- Parameters:
statementInspector
- The StatementInspector- Returns:
this
, for method chaining- See Also:
JdbcSettings.STATEMENT_INSPECTOR
-
addSessionFactoryObservers
public T addSessionFactoryObservers(SessionFactoryObserver... observers)
Description copied from interface:SessionFactoryBuilder
Specifies one or more observers. May be called multiple times to add additional observers.- Specified by:
addSessionFactoryObservers
in interfaceSessionFactoryBuilder
- Parameters:
observers
- The observers to add- Returns:
this
, for method chaining- See Also:
PersistenceSettings.SESSION_FACTORY_OBSERVER
-
applyCustomEntityDirtinessStrategy
public T applyCustomEntityDirtinessStrategy(CustomEntityDirtinessStrategy strategy)
Description copied from interface:SessionFactoryBuilder
Specifies aCustomEntityDirtinessStrategy
.- Specified by:
applyCustomEntityDirtinessStrategy
in 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:SessionFactoryBuilder
Specifies one or more entity name resolvers. May be called multiple times to add additional resolvers.- Specified by:
addEntityNameResolver
in interfaceSessionFactoryBuilder
- Parameters:
entityNameResolvers
- The entityNameResolvers to add- Returns:
this
, for method chaining
-
applyEntityNotFoundDelegate
public T applyEntityNotFoundDelegate(EntityNotFoundDelegate entityNotFoundDelegate)
Description copied from interface:SessionFactoryBuilder
Specifies anEntityNotFoundDelegate
. AnEntityNotFoundDelegate
is a strategy that accounts for different exceptions thrown between Hibernate and JPA when an entity cannot be found.- Specified by:
applyEntityNotFoundDelegate
in interfaceSessionFactoryBuilder
- Parameters:
entityNotFoundDelegate
- The delegate/strategy to use.- Returns:
this
, for method chaining
-
applyIdentifierRollbackSupport
public T applyIdentifierRollbackSupport(boolean enabled)
Description copied from interface:SessionFactoryBuilder
Should the generated identifier be "unset" when an entity is deleted?- Specified by:
applyIdentifierRollbackSupport
in interfaceSessionFactoryBuilder
- Parameters:
enabled
-true
indicates identifiers should be unset;false
indicates not.- Returns:
this
, for method chaining- See Also:
AvailableSettings.USE_IDENTIFIER_ROLLBACK
-
applyNullabilityChecking
public T applyNullabilityChecking(boolean enabled)
Description copied from interface:SessionFactoryBuilder
Should attributes using columns marked as not-null be checked (by Hibernate) for nullness, or should this be left as a job for the database?- Specified by:
applyNullabilityChecking
in interfaceSessionFactoryBuilder
- Parameters:
enabled
-true
indicates that Hibernate should perform nullness checking;false
indicates it should not.- Returns:
this
, for method chaining- See Also:
ValidationSettings.CHECK_NULLABILITY
-
applyLazyInitializationOutsideTransaction
public T applyLazyInitializationOutsideTransaction(boolean enabled)
Description copied from interface:SessionFactoryBuilder
Should the application be allowed to initialize uninitialized lazy state outside the bounds of a transaction?- Specified by:
applyLazyInitializationOutsideTransaction
in interfaceSessionFactoryBuilder
- Parameters:
enabled
-true
indicates initialization outside the transaction should be allowed;false
indicates it should not.- Returns:
this
, for method chaining- See Also:
TransactionSettings.ENABLE_LAZY_LOAD_NO_TRANS
-
applyTempTableDdlTransactionHandling
public T applyTempTableDdlTransactionHandling(TempTableDdlTransactionHandling handling)
- Specified by:
applyTempTableDdlTransactionHandling
in interfaceSessionFactoryBuilder
-
applyBatchFetchStyle
public T applyBatchFetchStyle(BatchFetchStyle style)
Description copied from interface:SessionFactoryBuilder
What style of batching should be used?- Specified by:
applyBatchFetchStyle
in interfaceSessionFactoryBuilder
- Parameters:
style
- The style to use- Returns:
this
, for method chaining- See Also:
FetchSettings.BATCH_FETCH_STYLE
-
applyDelayedEntityLoaderCreations
public SessionFactoryBuilder applyDelayedEntityLoaderCreations(boolean delay)
Description copied from interface:SessionFactoryBuilder
Should entity loaders be generated immediately? Or should the creation be delayed until first need?- Specified by:
applyDelayedEntityLoaderCreations
in interfaceSessionFactoryBuilder
- See Also:
AvailableSettings.DELAY_ENTITY_LOADER_CREATIONS
-
applyDefaultBatchFetchSize
public T applyDefaultBatchFetchSize(int size)
Description copied from interface:SessionFactoryBuilder
Specifies a default batch fetch size for all entities and collections which do not otherwise specify a batch fetch size.- Specified by:
applyDefaultBatchFetchSize
in 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:
FetchSettings.DEFAULT_BATCH_FETCH_SIZE
-
applyMaximumFetchDepth
public T applyMaximumFetchDepth(int depth)
Description copied from interface:SessionFactoryBuilder
Apply a limit to the depth Hibernate will use for outer joins.Note that this is different to an overall limit on the number of joins.
- Specified by:
applyMaximumFetchDepth
in interfaceSessionFactoryBuilder
- Parameters:
depth
- The depth for limiting joins.- Returns:
this
, for method chaining- See Also:
FetchSettings.MAX_FETCH_DEPTH
-
applySubselectFetchEnabled
public SessionFactoryBuilder applySubselectFetchEnabled(boolean enabled)
Description copied from interface:SessionFactoryBuilder
Enable the use of subselect fetching.- Specified by:
applySubselectFetchEnabled
in interfaceSessionFactoryBuilder
- Parameters:
enabled
-true
indicates that subselect fetching is enabled- Returns:
this
, for method chaining- See Also:
FetchSettings.USE_SUBSELECT_FETCH
-
applyDefaultNullPrecedence
public T applyDefaultNullPrecedence(NullPrecedence nullPrecedence)
Description copied from interface:SessionFactoryBuilder
Apply a null precedence,NULLS FIRST
orNULLS LAST
, toorder by
clauses rendered in SQL queries.- Specified by:
applyDefaultNullPrecedence
in interfaceSessionFactoryBuilder
- Parameters:
nullPrecedence
- The default null precedence to use.- Returns:
this
, for method chaining- See Also:
QuerySettings.DEFAULT_NULL_ORDERING
-
applyOrderingOfInserts
public T applyOrderingOfInserts(boolean enabled)
Description copied from interface:SessionFactoryBuilder
Specify whether ordering of inserts should be enabled.This allows more efficient SQL execution via the use of batching for the inserts; the cost is that the determination of the ordering is far less efficient than not ordering.
- Specified by:
applyOrderingOfInserts
in interfaceSessionFactoryBuilder
- Parameters:
enabled
-true
indicates that ordering should be enabled;false
indicates not- Returns:
this
, for method chaining- See Also:
BatchSettings.ORDER_INSERTS
-
applyOrderingOfUpdates
public T applyOrderingOfUpdates(boolean enabled)
Description copied from interface:SessionFactoryBuilder
Specify whether ordering of updates should be enabled.This allows more efficient SQL execution via the use of batching for the updates; the cost is that the determination of the ordering is far less efficient than not ordering.
- Specified by:
applyOrderingOfUpdates
in interfaceSessionFactoryBuilder
- Parameters:
enabled
-true
indicates that ordering should be enabled;false
indicates not- Returns:
this
, for method chaining- See Also:
BatchSettings.ORDER_UPDATES
-
applyMultiTenancy
public T applyMultiTenancy(boolean enabled)
Description copied from interface:SessionFactoryBuilder
Specifies whether multi-tenancy is enabled- Specified by:
applyMultiTenancy
in interfaceSessionFactoryBuilder
- Parameters:
enabled
- True if multi-tenancy in use.- Returns:
this
, for method chaining
-
applyCurrentTenantIdentifierResolver
public T applyCurrentTenantIdentifierResolver(CurrentTenantIdentifierResolver<?> resolver)
Description copied from interface:SessionFactoryBuilder
Specifies aCurrentTenantIdentifierResolver
that is responsible for resolving the current tenant identifier.- Specified by:
applyCurrentTenantIdentifierResolver
in interfaceSessionFactoryBuilder
- Parameters:
resolver
- The resolution strategy to use.- Returns:
this
, for method chaining- See Also:
MultiTenancySettings.MULTI_TENANT_IDENTIFIER_RESOLVER
-
applyJtaTrackingByThread
public T applyJtaTrackingByThread(boolean enabled)
Description copied from interface:SessionFactoryBuilder
If using the built-in JTA-basedTransactionCoordinator
orTransactionCoordinatorBuilder
, should it track JTA transactions by thread in an attempt to detect timeouts?- Specified by:
applyJtaTrackingByThread
in interfaceSessionFactoryBuilder
- Parameters:
enabled
-true
indicates we should track by thread;false
indicates not- Returns:
this
, for method chaining- See Also:
TransactionSettings.JTA_TRACK_BY_THREAD
-
applyPreferUserTransactions
public T applyPreferUserTransactions(boolean preferUserTransactions)
Description copied from interface:SessionFactoryBuilder
If using the built-in JTA-basedTransactionCoordinator
orTransactionCoordinatorBuilder
, should it prefer to useUserTransaction
in preference toTransaction
?- Specified by:
applyPreferUserTransactions
in interfaceSessionFactoryBuilder
- Parameters:
preferUserTransactions
-true
indicates we should preferUserTransaction
;false
indicates we should preferTransaction
- Returns:
this
, for method chaining- See Also:
TransactionSettings.PREFER_USER_TRANSACTION
-
applyNamedQueryCheckingOnStartup
public T applyNamedQueryCheckingOnStartup(boolean enabled)
Description copied from interface:SessionFactoryBuilder
Should named queries be checked on startup?- Specified by:
applyNamedQueryCheckingOnStartup
in interfaceSessionFactoryBuilder
- Parameters:
enabled
-true
indicates that they should;false
indicates they should not.- Returns:
this
, for method chaining- See Also:
QuerySettings.QUERY_STARTUP_CHECKING
-
applySecondLevelCacheSupport
public T applySecondLevelCacheSupport(boolean enabled)
Description copied from interface:SessionFactoryBuilder
Should second level caching support be enabled?- Specified by:
applySecondLevelCacheSupport
in interfaceSessionFactoryBuilder
- Parameters:
enabled
-true
indicates we should enable the use of second level caching;false
indicates we should disable the use of second level caching.- Returns:
this
, for method chaining- See Also:
CacheSettings.USE_SECOND_LEVEL_CACHE
-
applyQueryCacheSupport
public T applyQueryCacheSupport(boolean enabled)
Description copied from interface:SessionFactoryBuilder
Should second level query caching support be enabled?- Specified by:
applyQueryCacheSupport
in interfaceSessionFactoryBuilder
- Parameters:
enabled
-true
indicates we should enable the use of second level query caching;false
indicates we should disable the use of second level query caching.- Returns:
this
, for method chaining- See Also:
CacheSettings.USE_QUERY_CACHE
-
applyQueryCacheLayout
public SessionFactoryBuilder applyQueryCacheLayout(CacheLayout cacheLayout)
Description copied from interface:SessionFactoryBuilder
Specifies the defaultCacheLayout
to use for query cache entries.- Specified by:
applyQueryCacheLayout
in interfaceSessionFactoryBuilder
- Parameters:
cacheLayout
- The cache layout to use.- Returns:
this
, for method chaining- See Also:
CacheSettings.QUERY_CACHE_LAYOUT
-
applyTimestampsCacheFactory
public SessionFactoryBuilder applyTimestampsCacheFactory(TimestampsCacheFactory factory)
Description copied from interface:SessionFactoryBuilder
Specifies aTimestampsCacheFactory
.- Specified by:
applyTimestampsCacheFactory
in interfaceSessionFactoryBuilder
- Parameters:
factory
- TheTimestampsCacheFactory
to use- Returns:
this
, for method chaining- See Also:
CacheSettings.QUERY_CACHE_FACTORY
-
applyCacheRegionPrefix
public T applyCacheRegionPrefix(String prefix)
Description copied from interface:SessionFactoryBuilder
Specify a prefix to prepended to all cache region names.- Specified by:
applyCacheRegionPrefix
in interfaceSessionFactoryBuilder
- Parameters:
prefix
- The prefix.- Returns:
this
, for method chaining- See Also:
CacheSettings.CACHE_REGION_PREFIX
-
applyMinimalPutsForCaching
public T applyMinimalPutsForCaching(boolean enabled)
Description copied from interface:SessionFactoryBuilder
By 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 it's very rare that users need to set this, generally speaking.
- Specified by:
applyMinimalPutsForCaching
in interfaceSessionFactoryBuilder
- Parameters:
enabled
-true
indicates Hibernate should first check whether data exists and only push to the cache if it does not already exist.false
indicates to perform the default behavior.- Returns:
this
, for method chaining- See Also:
CacheSettings.USE_MINIMAL_PUTS
,RegionFactory.isMinimalPutsEnabledByDefault()
-
applyStructuredCacheEntries
public T applyStructuredCacheEntries(boolean enabled)
Description copied from interface:SessionFactoryBuilder
By 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:
applyStructuredCacheEntries
in interfaceSessionFactoryBuilder
- Parameters:
enabled
-true
indicates that structured (human-readable) cache entries should be used;false
indicates that the native entry structure should be used.- Returns:
this
, for method chaining- See Also:
CacheSettings.USE_STRUCTURED_CACHE
-
applyDirectReferenceCaching
public T applyDirectReferenceCaching(boolean enabled)
Description copied from interface:SessionFactoryBuilder
Generally, 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:
applyDirectReferenceCaching
in interfaceSessionFactoryBuilder
- Parameters:
enabled
-true
indicates 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:
CacheSettings.USE_DIRECT_REFERENCE_CACHE_ENTRIES
-
applyAutomaticEvictionOfCollectionCaches
public T applyAutomaticEvictionOfCollectionCaches(boolean enabled)
Description copied from interface:SessionFactoryBuilder
When using bidirectional 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 bidirectional 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:
applyAutomaticEvictionOfCollectionCaches
in interfaceSessionFactoryBuilder
- Parameters:
enabled
-true
indicates that these collection caches should be evicted automatically.- Returns:
this
, for method chaining- See Also:
CacheSettings.AUTO_EVICT_COLLECTION_CACHE
-
applyJdbcBatchSize
public T applyJdbcBatchSize(int size)
Description copied from interface:SessionFactoryBuilder
Specifies 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:
applyJdbcBatchSize
in interfaceSessionFactoryBuilder
- Parameters:
size
- The batch size to use.- Returns:
this
, for method chaining- See Also:
BatchSettings.STATEMENT_BATCH_SIZE
-
applyJdbcBatchingForVersionedEntities
public T applyJdbcBatchingForVersionedEntities(boolean enabled)
Description copied from interface:SessionFactoryBuilder
This 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 isfalse
by default.- Specified by:
applyJdbcBatchingForVersionedEntities
in interfaceSessionFactoryBuilder
- Parameters:
enabled
- The batch size to use.- Returns:
this
, for method chaining- See Also:
BatchSettings.BATCH_VERSIONED_DATA
-
applyScrollableResultsSupport
public T applyScrollableResultsSupport(boolean enabled)
Description copied from interface:SessionFactoryBuilder
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. Also, needed if user is supplying connections (and so no Connection is available when we bootstrap).- Specified by:
applyScrollableResultsSupport
in interfaceSessionFactoryBuilder
- Parameters:
enabled
-true
to enable this support,false
to disable it- Returns:
this
, for method chaining- See Also:
JdbcSettings.USE_SCROLLABLE_RESULTSET
-
applyGetGeneratedKeysSupport
public T applyGetGeneratedKeysSupport(boolean enabled)
Description copied from interface:SessionFactoryBuilder
Should JDBCStatement.getGeneratedKeys()
feature be used for retrieval of *insert-generated* ids?- Specified by:
applyGetGeneratedKeysSupport
in interfaceSessionFactoryBuilder
- Parameters:
enabled
-true
indicates we should use JDBC getGeneratedKeys support;false
indicates we should not.- Returns:
this
, for method chaining- See Also:
JdbcSettings.USE_GET_GENERATED_KEYS
-
applyJdbcFetchSize
public T applyJdbcFetchSize(int size)
Description copied from interface:SessionFactoryBuilder
Apply a fetch size to the JDBC driver for fetching results.- Specified by:
applyJdbcFetchSize
in interfaceSessionFactoryBuilder
- Parameters:
size
- The fetch size to be passed to the driver.- Returns:
this
, for method chaining- See Also:
JdbcSettings.STATEMENT_FETCH_SIZE
,Statement.setFetchSize(int)
-
applyConnectionProviderDisablesAutoCommit
public SessionFactoryBuilder applyConnectionProviderDisablesAutoCommit(boolean providerDisablesAutoCommit)
- Specified by:
applyConnectionProviderDisablesAutoCommit
in interfaceSessionFactoryBuilder
- See Also:
JdbcSettings.CONNECTION_PROVIDER_DISABLES_AUTOCOMMIT
-
applySqlComments
public T applySqlComments(boolean enabled)
Description copied from interface:SessionFactoryBuilder
Should Hibernate apply comments to SQL it generates?- Specified by:
applySqlComments
in interfaceSessionFactoryBuilder
- Parameters:
enabled
-true
indicates comments should be applied;false
indicates not.- Returns:
this
, for method chaining- See Also:
JdbcSettings.USE_SQL_COMMENTS
-
applySqlFunction
public T applySqlFunction(String registrationName, SqmFunctionDescriptor sqlFunction)
Description copied from interface:SessionFactoryBuilder
Register aSQL function
with the underlyingSqmFunctionRegistry
.- Specified by:
applySqlFunction
in interfaceSessionFactoryBuilder
- Parameters:
registrationName
- The function name to register it undersqlFunction
- TheSqmFunctionDescriptor
- Returns:
this
, for method chaining
-
applyCollectionsInDefaultFetchGroup
public SessionFactoryBuilder applyCollectionsInDefaultFetchGroup(boolean enabled)
Description copied from interface:SessionFactoryBuilder
Should collections be included in the default fetch group when bytecode enhancement is used?- Specified by:
applyCollectionsInDefaultFetchGroup
in interfaceSessionFactoryBuilder
- Parameters:
enabled
-true
collections should be included,false
they should not. Default istrue
.- Returns:
this
, for method chaining
-
allowOutOfTransactionUpdateOperations
public T allowOutOfTransactionUpdateOperations(boolean allow)
- Specified by:
allowOutOfTransactionUpdateOperations
in interfaceSessionFactoryBuilder
- See Also:
TransactionSettings.ALLOW_UPDATE_OUTSIDE_TRANSACTION
-
enableReleaseResourcesOnCloseEnabled
public T enableReleaseResourcesOnCloseEnabled(boolean enable)
Description copied from interface:SessionFactoryBuilder
Should resources held by anEntityManager
be released immediately on close?The other option is to release them as part of an after transaction callback.
- Specified by:
enableReleaseResourcesOnCloseEnabled
in interfaceSessionFactoryBuilder
-
enableJpaQueryCompliance
public SessionFactoryBuilder enableJpaQueryCompliance(boolean enabled)
- Specified by:
enableJpaQueryCompliance
in interfaceSessionFactoryBuilder
- See Also:
JpaCompliance.isJpaQueryComplianceEnabled()
,JpaComplianceSettings.JPA_QUERY_COMPLIANCE
-
enableJpaOrderByMappingCompliance
public SessionFactoryBuilder enableJpaOrderByMappingCompliance(boolean enabled)
- Specified by:
enableJpaOrderByMappingCompliance
in interfaceSessionFactoryBuilder
- See Also:
JpaCompliance.isJpaQueryComplianceEnabled()
,JpaComplianceSettings.JPA_ORDER_BY_MAPPING_COMPLIANCE
-
enableJpaTransactionCompliance
public SessionFactoryBuilder enableJpaTransactionCompliance(boolean enabled)
- Specified by:
enableJpaTransactionCompliance
in interfaceSessionFactoryBuilder
- See Also:
JpaCompliance.isJpaTransactionComplianceEnabled()
,JpaComplianceSettings.JPA_TRANSACTION_COMPLIANCE
-
enableJpaListCompliance
public SessionFactoryBuilder enableJpaListCompliance(boolean enabled)
- Specified by:
enableJpaListCompliance
in interfaceSessionFactoryBuilder
- See Also:
JpaCompliance.isJpaListComplianceEnabled()
,JpaComplianceSettings.JPA_LIST_COMPLIANCE
-
enableJpaClosedCompliance
public SessionFactoryBuilder enableJpaClosedCompliance(boolean enabled)
- Specified by:
enableJpaClosedCompliance
in interfaceSessionFactoryBuilder
- See Also:
JpaCompliance.isJpaClosedComplianceEnabled()
,JpaComplianceSettings.JPA_CLOSED_COMPLIANCE
-
applyStatelessInterceptor
public T applyStatelessInterceptor(Supplier<? extends Interceptor> statelessInterceptorSupplier)
Description copied from interface:SessionFactoryBuilder
Specifies an interceptorSupplier
associated with theSessionFactory
, which is used to obtain an interceptor for each session, unless an interceptor is explicitly specified usingSessionBuilder.interceptor(org.hibernate.Interceptor)
.- Specified by:
applyStatelessInterceptor
in interfaceSessionFactoryBuilder
- Parameters:
statelessInterceptorSupplier
-Supplier
instance which is used to retrieve the interceptor- Returns:
this
, for method chaining- See Also:
SessionEventSettings.SESSION_SCOPED_INTERCEPTOR
-
applyStatelessInterceptor
public T applyStatelessInterceptor(Class<? extends Interceptor> statelessInterceptorClass)
Description copied from interface:SessionFactoryBuilder
Specifies an interceptorClass
associated with theSessionFactory
, which is used to instantiate a new interceptor for each session, unless an interceptor is explicitly specified usingSessionBuilder.interceptor(org.hibernate.Interceptor)
.- Specified by:
applyStatelessInterceptor
in interfaceSessionFactoryBuilder
- Parameters:
statelessInterceptorClass
- The interceptor class- Returns:
this
, for method chaining- See Also:
SessionEventSettings.SESSION_SCOPED_INTERCEPTOR
-
applyConnectionHandlingMode
public T applyConnectionHandlingMode(PhysicalConnectionHandlingMode connectionHandlingMode)
Description copied from interface:SessionFactoryBuilder
Specifies the connection handling mode for JDBC connections.- Specified by:
applyConnectionHandlingMode
in interfaceSessionFactoryBuilder
- Parameters:
connectionHandlingMode
- The handling mode to apply- Returns:
this
, for method chaining- See Also:
JdbcSettings.CONNECTION_HANDLING
,PhysicalConnectionHandlingMode
,ConnectionAcquisitionMode
,ConnectionReleaseMode
-
applyJsonFormatMapper
public SessionFactoryBuilder applyJsonFormatMapper(FormatMapper jsonFormatMapper)
Description copied from interface:SessionFactoryBuilder
Specifies aformat mapper
to use for serialization/deserialization of JSON properties.- Specified by:
applyJsonFormatMapper
in interfaceSessionFactoryBuilder
- Parameters:
jsonFormatMapper
- TheFormatMapper
to use.- Returns:
this
, for method chaining- See Also:
MappingSettings.JSON_FORMAT_MAPPER
-
applyXmlFormatMapper
public SessionFactoryBuilder applyXmlFormatMapper(FormatMapper xmlFormatMapper)
Description copied from interface:SessionFactoryBuilder
Specifies aformat mapper
to use for serialization/deserialization of XML properties.- Specified by:
applyXmlFormatMapper
in interfaceSessionFactoryBuilder
- Parameters:
xmlFormatMapper
- TheFormatMapper
to use.- Returns:
this
, for method chaining- See Also:
MappingSettings.XML_FORMAT_MAPPER
-
build
public SessionFactory build()
Description copied from interface:SessionFactoryBuilder
After all options have been set, build the SessionFactory.- Specified by:
build
in interfaceSessionFactoryBuilder
- Returns:
- The built SessionFactory.
-
-