Package org.hibernate.boot
Interface SessionFactoryBuilder
-
- All Known Subinterfaces:
SessionFactoryBuilderImplementor
- All Known Implementing Classes:
AbstractDelegatingSessionFactoryBuilder
,AbstractDelegatingSessionFactoryBuilderImplementor
public interface SessionFactoryBuilder
The contract for building aSessionFactory
given a number of options.- Since:
- 5.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description SessionFactoryBuilder
addEntityNameResolver(EntityNameResolver... entityNameResolvers)
Specifies one or more entity name resolvers to be applied to the SessionFactory (see theEntityNameResolver
contract for more information..SessionFactoryBuilder
addSessionFactoryObservers(SessionFactoryObserver... observers)
Specifies one or more observers to be applied to the SessionFactory.SessionFactoryBuilder
allowOutOfTransactionUpdateOperations(boolean allow)
SessionFactoryBuilder
applyAutoClosing(boolean enabled)
Applies whether Sessions should be automatically closed at the end of the transaction.SessionFactoryBuilder
applyAutoFlushing(boolean enabled)
Applies whether Sessions should be automatically flushed at the end of the transaction.SessionFactoryBuilder
applyAutomaticEvictionOfCollectionCaches(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).SessionFactoryBuilder
applyBatchFetchStyle(BatchFetchStyle style)
What style of batching should be used?SessionFactoryBuilder
applyBeanManager(java.lang.Object beanManager)
Apply a CDI BeanManager to the SessionFactory being built.SessionFactoryBuilder
applyCacheRegionPrefix(java.lang.String prefix)
Apply a prefix to prepended to all cache region names for this SessionFactory.SessionFactoryBuilder
applyConnectionHandlingMode(PhysicalConnectionHandlingMode connectionHandlingMode)
Apply the specified handling mode for JDBC connectionsdefault SessionFactoryBuilder
applyConnectionProviderDisablesAutoCommit(boolean providerDisablesAutoCommit)
SessionFactoryBuilder
applyConnectionReleaseMode(ConnectionReleaseMode connectionReleaseMode)
Deprecated.SessionFactoryBuilder
applyCurrentTenantIdentifierResolver(CurrentTenantIdentifierResolver resolver)
Specifies a strategy for resolving the notion of a "current" tenant-identifier when using multi-tenancy together with current sessionsSessionFactoryBuilder
applyCustomEntityDirtinessStrategy(CustomEntityDirtinessStrategy strategy)
Specifies a custom entity dirtiness strategy to be applied to the SessionFactory.SessionFactoryBuilder
applyDefaultBatchFetchSize(int size)
Allows specifying a default batch-fetch size for all entities and collections which do not otherwise specify a batch-fetch size.SessionFactoryBuilder
applyDefaultEntityMode(EntityMode entityMode)
Deprecated.Different entity modes per entity is soon to be removed as a feature.SessionFactoryBuilder
applyDefaultNullPrecedence(NullPrecedence nullPrecedence)
Apply a null precedence (NULLS FIRST, NULLS LAST) to be applied order-by clauses rendered into SQL queries.SessionFactoryBuilder
applyDelayedEntityLoaderCreations(boolean delay)
Should entity Loaders be generated immediately? Or should the creation be delayed until first need?SessionFactoryBuilder
applyDirectReferenceCaching(boolean enabled)
Generally, Hibernate will extract the information from an entity and put that extracted information into the second-level cache.SessionFactoryBuilder
applyEntityNotFoundDelegate(EntityNotFoundDelegate entityNotFoundDelegate)
Names theEntityNotFoundDelegate
to be applied to the SessionFactory.SessionFactoryBuilder
applyEntityTuplizer(EntityMode entityMode, java.lang.Class<? extends EntityTuplizer> tuplizerClass)
Register the defaultEntityTuplizer
to be applied to the SessionFactory.SessionFactoryBuilder
applyEntityTuplizerFactory(EntityTuplizerFactory entityTuplizerFactory)
Specify the EntityTuplizerFactory to use.SessionFactoryBuilder
applyGetGeneratedKeysSupport(boolean enabled)
Should JDBCStatement.getGeneratedKeys()
feature be used for retrieval of *insert-generated* ids?SessionFactoryBuilder
applyIdentifierRollbackSupport(boolean enabled)
Should generated identifiers be "unset" on entities during a rollback?SessionFactoryBuilder
applyInterceptor(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)
SessionFactoryBuilder
applyJdbcBatchingForVersionedEntities(boolean enabled)
This setting controls whether versioned entities will be included in JDBC batching.SessionFactoryBuilder
applyJdbcBatchSize(int size)
Specifies the maximum number of statements to batch together in a JDBC batch for insert, update and delete operations.SessionFactoryBuilder
applyJdbcFetchSize(int size)
Apply a fetch size to the JDBC driver for fetching results.SessionFactoryBuilder
applyJtaTrackingByThread(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?SessionFactoryBuilder
applyLazyInitializationOutsideTransaction(boolean enabled)
Should the application be allowed to initialize uninitialized lazy state outside the bounds of a transaction?SessionFactoryBuilder
applyMaximumFetchDepth(int depth)
Apply a limit to the depth Hibernate will use for outer joins.SessionFactoryBuilder
applyMinimalPutsForCaching(boolean enabled)
By default, Hibernate will always just push data into the cache without first checking if that data already exists.SessionFactoryBuilder
applyMultiTableBulkIdStrategy(MultiTableBulkIdStrategy strategy)
How should updates and deletes that span multiple tables be handled?SessionFactoryBuilder
applyMultiTenancyStrategy(MultiTenancyStrategy strategy)
Apply the form of multi-tenancy used by the applicationSessionFactoryBuilder
applyName(java.lang.String sessionFactoryName)
Applies a SessionFactory name.SessionFactoryBuilder
applyNameAsJndiName(boolean isJndiName)
Applies a SessionFactory name.SessionFactoryBuilder
applyNamedQueryCheckingOnStartup(boolean enabled)
Should named queries be checked on startup?SessionFactoryBuilder
applyNullabilityChecking(boolean enabled)
Should attributes using columns marked as not-null be checked (by Hibernate) for nullness?SessionFactoryBuilder
applyOrderingOfInserts(boolean enabled)
Apply whether ordering of inserts should be enabled.SessionFactoryBuilder
applyOrderingOfUpdates(boolean enabled)
Apply whether ordering of updates should be enabled.SessionFactoryBuilder
applyPreferUserTransactions(boolean preferUserTransactions)
If using the built-in Hibernate JTA-based TransactionCoordinator/Builder, should it prefer to useUserTransaction
overTransaction
?SessionFactoryBuilder
applyQueryCacheSupport(boolean enabled)
Should second level query caching support be enabled?SessionFactoryBuilder
applyQuerySubstitutions(java.util.Map substitutions)
Deprecated.This is a legacy feature and should never be needed anymore...SessionFactoryBuilder
applyResultSetsWrapping(boolean enabled)
Hibernate currently accesses results from the JDBC ResultSet by name.SessionFactoryBuilder
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.SessionFactoryBuilder
applySecondLevelCacheSupport(boolean enabled)
Should second level caching support be enabled?SessionFactoryBuilder
applySqlComments(boolean enabled)
Should Hibernate apply comments to SQL it generates?SessionFactoryBuilder
applySqlFunction(java.lang.String registrationName, SQLFunction sqlFunction)
Apply a SQLFunction to the underlyingSQLFunctionRegistry
.SessionFactoryBuilder
applyStatelessInterceptor(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)
SessionFactoryBuilder
applyStatelessInterceptor(java.util.function.Supplier<? extends Interceptor> statelessInterceptorSupplier)
Names aSupplier
instance 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)
SessionFactoryBuilder
applyStatementInspector(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)
SessionFactoryBuilder
applyStatisticsSupport(boolean enabled)
Applies whether statistics gathering is enabled.SessionFactoryBuilder
applyStrictJpaQueryLanguageCompliance(boolean enabled)
Deprecated.UseenableJpaQueryCompliance(boolean)
insteadSessionFactoryBuilder
applyStructuredCacheEntries(boolean enabled)
By default, Hibernate stores data in the cache in its own optimized format.SessionFactoryBuilder
applyTempTableDdlTransactionHandling(TempTableDdlTransactionHandling handling)
SessionFactoryBuilder
applyTimestampsCacheFactory(TimestampsCacheFactory factory)
Specifies a QueryCacheFactory to use for building query cache handlers.SessionFactoryBuilder
applyValidatorFactory(java.lang.Object validatorFactory)
Apply a Bean Validation ValidatorFactory to the SessionFactory being built.SessionFactory
build()
After all options have been set, build the SessionFactory.SessionFactoryBuilder
enableJpaClosedCompliance(boolean enabled)
SessionFactoryBuilder
enableJpaListCompliance(boolean enabled)
SessionFactoryBuilder
enableJpaQueryCompliance(boolean enabled)
SessionFactoryBuilder
enableJpaTransactionCompliance(boolean enabled)
SessionFactoryBuilder
enableReleaseResourcesOnCloseEnabled(boolean enable)
Should resources held byEntityManager
instance be released immediately on close?<T extends SessionFactoryBuilder>
Tunwrap(java.lang.Class<T> type)
Allows unwrapping this builder as another, more specific type.
-
-
-
Method Detail
-
applyValidatorFactory
SessionFactoryBuilder applyValidatorFactory(java.lang.Object validatorFactory)
Apply a Bean Validation ValidatorFactory to the SessionFactory being built. NOTE : De-typed to avoid hard dependency on Bean Validation jar at runtime.- Parameters:
validatorFactory
- The Bean Validation ValidatorFactory to use- Returns:
this
, for method chaining
-
applyBeanManager
SessionFactoryBuilder applyBeanManager(java.lang.Object beanManager)
Apply a CDI BeanManager to the SessionFactory being built. NOTE : De-typed to avoid hard dependency on CDI jar at runtime.- Parameters:
beanManager
- The CDI BeanManager to use- Returns:
this
, for method chaining
-
applyName
SessionFactoryBuilder applyName(java.lang.String sessionFactoryName)
Applies a SessionFactory name.- Parameters:
sessionFactoryName
- The name to use for the SessionFactory being built- Returns:
this
, for method chaining- See Also:
AvailableSettings.SESSION_FACTORY_NAME
-
applyNameAsJndiName
SessionFactoryBuilder applyNameAsJndiName(boolean isJndiName)
Applies a SessionFactory name.- Parameters:
isJndiName
-true
indicates that the name specified inapplyName(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
SessionFactoryBuilder applyAutoClosing(boolean enabled)
Applies whether Sessions should be automatically closed at the end of the transaction.- Parameters:
enabled
-true
indicates they should be auto-closed;false
indicates not.- Returns:
this
, for method chaining- See Also:
AvailableSettings.AUTO_CLOSE_SESSION
-
applyAutoFlushing
SessionFactoryBuilder applyAutoFlushing(boolean enabled)
Applies whether Sessions should be automatically flushed at the end of the transaction.- Parameters:
enabled
-true
indicates they should be auto-flushed;false
indicates not.- Returns:
this
, for method chaining- See Also:
AvailableSettings.FLUSH_BEFORE_COMPLETION
-
applyStatisticsSupport
SessionFactoryBuilder applyStatisticsSupport(boolean enabled)
Applies whether statistics gathering is enabled.- Parameters:
enabled
-true
indicates that statistics gathering should be enabled;false
indicates not.- Returns:
this
, for method chaining- See Also:
AvailableSettings.GENERATE_STATISTICS
-
applyInterceptor
SessionFactoryBuilder applyInterceptor(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)
- Parameters:
interceptor
- The interceptor- Returns:
this
, for method chaining- See Also:
AvailableSettings.INTERCEPTOR
-
applyStatelessInterceptor
SessionFactoryBuilder applyStatelessInterceptor(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)
- Parameters:
statelessInterceptorClass
- The interceptor class- Returns:
this
, for method chaining- See Also:
AvailableSettings.SESSION_SCOPED_INTERCEPTOR
-
applyStatelessInterceptor
SessionFactoryBuilder applyStatelessInterceptor(java.util.function.Supplier<? extends Interceptor> statelessInterceptorSupplier)
Names aSupplier
instance 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)
- Parameters:
statelessInterceptorSupplier
-Supplier
instance which is used to retrieve the interceptor- Returns:
this
, for method chaining- See Also:
AvailableSettings.SESSION_SCOPED_INTERCEPTOR
-
applyStatementInspector
SessionFactoryBuilder applyStatementInspector(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)
- Parameters:
statementInspector
- The StatementInspector- Returns:
this
, for method chaining- See Also:
AvailableSettings.STATEMENT_INSPECTOR
-
addSessionFactoryObservers
SessionFactoryBuilder addSessionFactoryObservers(SessionFactoryObserver... observers)
Specifies one or more observers to be applied to the SessionFactory. Can be called multiple times to add additional observers.- Parameters:
observers
- The observers to add- Returns:
this
, for method chaining
-
applyCustomEntityDirtinessStrategy
SessionFactoryBuilder applyCustomEntityDirtinessStrategy(CustomEntityDirtinessStrategy strategy)
Specifies a custom entity dirtiness strategy to be applied to the SessionFactory. See the contract ofCustomEntityDirtinessStrategy
for details.- Parameters:
strategy
- The custom strategy to be used.- Returns:
this
, for method chaining- See Also:
AvailableSettings.CUSTOM_ENTITY_DIRTINESS_STRATEGY
-
addEntityNameResolver
SessionFactoryBuilder addEntityNameResolver(EntityNameResolver... entityNameResolvers)
Specifies one or more entity name resolvers to be applied to the SessionFactory (see theEntityNameResolver
contract for more information.. Can be called multiple times to add additional resolvers..- Parameters:
entityNameResolvers
- The entityNameResolvers to add- Returns:
this
, for method chaining
-
applyEntityNotFoundDelegate
SessionFactoryBuilder applyEntityNotFoundDelegate(EntityNotFoundDelegate entityNotFoundDelegate)
Names theEntityNotFoundDelegate
to 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.- Parameters:
entityNotFoundDelegate
- The delegate/strategy to use.- Returns:
this
, for method chaining
-
applyIdentifierRollbackSupport
SessionFactoryBuilder applyIdentifierRollbackSupport(boolean enabled)
Should generated identifiers be "unset" on entities during a rollback?- Parameters:
enabled
-true
indicates identifiers should be unset;false
indicates not.- Returns:
this
, for method chaining- See Also:
AvailableSettings.USE_IDENTIFIER_ROLLBACK
-
applyDefaultEntityMode
@Deprecated SessionFactoryBuilder applyDefaultEntityMode(EntityMode entityMode)
Deprecated.Different entity modes per entity is soon to be removed as a feature.Applies the given entity mode as the default for the SessionFactory.- Parameters:
entityMode
- The default entity mode to use.- Returns:
this
, for method chaining- See Also:
AvailableSettings.DEFAULT_ENTITY_MODE
-
applyNullabilityChecking
SessionFactoryBuilder applyNullabilityChecking(boolean enabled)
Should attributes using columns marked as not-null be checked (by Hibernate) for nullness?- Parameters:
enabled
-true
indicates that Hibernate should perform nullness checking;false
indicates it should not.- Returns:
this
, for method chaining- See Also:
AvailableSettings.CHECK_NULLABILITY
-
applyLazyInitializationOutsideTransaction
SessionFactoryBuilder applyLazyInitializationOutsideTransaction(boolean enabled)
Should the application be allowed to initialize uninitialized lazy state outside the bounds of a transaction?- Parameters:
enabled
-true
indicates initialization outside the transaction should be allowed;false
indicates it should not.- Returns:
this
, for method chaining- See Also:
AvailableSettings.ENABLE_LAZY_LOAD_NO_TRANS
-
applyEntityTuplizerFactory
SessionFactoryBuilder applyEntityTuplizerFactory(EntityTuplizerFactory entityTuplizerFactory)
Specify the EntityTuplizerFactory to use.- Parameters:
entityTuplizerFactory
- The EntityTuplizerFactory to use.- Returns:
this
, for method chaining
-
applyEntityTuplizer
SessionFactoryBuilder applyEntityTuplizer(EntityMode entityMode, java.lang.Class<? extends EntityTuplizer> tuplizerClass)
Register the defaultEntityTuplizer
to be applied to the SessionFactory.- Parameters:
entityMode
- The entity mode that which this tuplizer will be applied.tuplizerClass
- The custom tuplizer class.- Returns:
this
, for method chaining
-
applyMultiTableBulkIdStrategy
SessionFactoryBuilder applyMultiTableBulkIdStrategy(MultiTableBulkIdStrategy strategy)
How should updates and deletes that span multiple tables be handled?- Parameters:
strategy
- The strategy for handling multi-table updates and deletes.- Returns:
this
, for method chaining- See Also:
AvailableSettings.HQL_BULK_ID_STRATEGY
-
applyTempTableDdlTransactionHandling
SessionFactoryBuilder applyTempTableDdlTransactionHandling(TempTableDdlTransactionHandling handling)
-
applyBatchFetchStyle
SessionFactoryBuilder applyBatchFetchStyle(BatchFetchStyle style)
What style of batching should be used?- Parameters:
style
- The style to use- Returns:
this
, for method chaining- See Also:
AvailableSettings.BATCH_FETCH_STYLE
-
applyDelayedEntityLoaderCreations
SessionFactoryBuilder applyDelayedEntityLoaderCreations(boolean delay)
Should entity Loaders be generated immediately? Or should the creation be delayed until first need?
-
applyDefaultBatchFetchSize
SessionFactoryBuilder applyDefaultBatchFetchSize(int size)
Allows specifying a default batch-fetch size for all entities and collections which do not otherwise specify a batch-fetch size.- 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
SessionFactoryBuilder applyMaximumFetchDepth(int depth)
Apply 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...- Parameters:
depth
- The depth for limiting joins.- Returns:
this
, for method chaining- See Also:
AvailableSettings.MAX_FETCH_DEPTH
-
applyDefaultNullPrecedence
SessionFactoryBuilder applyDefaultNullPrecedence(NullPrecedence nullPrecedence)
Apply a null precedence (NULLS FIRST, NULLS LAST) to be applied order-by clauses rendered into SQL queries.- Parameters:
nullPrecedence
- The default null precedence to use.- Returns:
this
, for method chaining- See Also:
AvailableSettings.DEFAULT_NULL_ORDERING
-
applyOrderingOfInserts
SessionFactoryBuilder applyOrderingOfInserts(boolean enabled)
Apply 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.- Parameters:
enabled
-true
indicates that ordering should be enabled;false
indicates not- Returns:
this
, for method chaining- See Also:
AvailableSettings.ORDER_INSERTS
-
applyOrderingOfUpdates
SessionFactoryBuilder applyOrderingOfUpdates(boolean enabled)
Apply 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.- Parameters:
enabled
-true
indicates that ordering should be enabled;false
indicates not- Returns:
this
, for method chaining- See Also:
AvailableSettings.ORDER_UPDATES
-
applyMultiTenancyStrategy
SessionFactoryBuilder applyMultiTenancyStrategy(MultiTenancyStrategy strategy)
Apply the form of multi-tenancy used by the application- Parameters:
strategy
- The form of multi-tenancy in use.- Returns:
this
, for method chaining- See Also:
AvailableSettings.MULTI_TENANT
-
applyCurrentTenantIdentifierResolver
SessionFactoryBuilder applyCurrentTenantIdentifierResolver(CurrentTenantIdentifierResolver resolver)
Specifies a strategy for resolving the notion of a "current" tenant-identifier when using multi-tenancy together with current sessions- Parameters:
resolver
- The resolution strategy to use.- Returns:
this
, for method chaining- See Also:
AvailableSettings.MULTI_TENANT_IDENTIFIER_RESOLVER
-
applyJtaTrackingByThread
SessionFactoryBuilder applyJtaTrackingByThread(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?- Parameters:
enabled
-true
indicates we should track by thread;false
indicates not- Returns:
this
, for method chaining- See Also:
AvailableSettings.JTA_TRACK_BY_THREAD
-
applyPreferUserTransactions
SessionFactoryBuilder applyPreferUserTransactions(boolean preferUserTransactions)
If using the built-in Hibernate JTA-based TransactionCoordinator/Builder, should it prefer to useUserTransaction
overTransaction
?- Parameters:
preferUserTransactions
-true
indicates we should preferUserTransaction
;false
indicates we should preferTransaction
- Returns:
this
, for method chaining- See Also:
AvailableSettings.PREFER_USER_TRANSACTION
-
applyQuerySubstitutions
@Deprecated SessionFactoryBuilder applyQuerySubstitutions(java.util.Map substitutions)
Deprecated.This is a legacy feature and should never be needed anymore...Apply query substitutions to use in HQL queries. Note, this is a legacy feature and almost always never needed anymore...- Parameters:
substitutions
- The substitution map- Returns:
this
, for method chaining- See Also:
AvailableSettings.QUERY_SUBSTITUTIONS
-
applyStrictJpaQueryLanguageCompliance
@Deprecated SessionFactoryBuilder applyStrictJpaQueryLanguageCompliance(boolean enabled)
Deprecated.UseenableJpaQueryCompliance(boolean)
insteadShould we strictly adhere to JPA Query Language (JPQL) syntax, or more broadly support all of Hibernate's superset (HQL)? Setting this totrue
may cause valid HQL to throw an exception because it violates the JPQL subset.- Parameters:
enabled
-true
indicates that we should strictly adhere to the JPQL subset;false
indicates we should accept the broader HQL syntax.- Returns:
this
, for method chaining- See Also:
AvailableSettings.JPAQL_STRICT_COMPLIANCE
-
applyNamedQueryCheckingOnStartup
SessionFactoryBuilder applyNamedQueryCheckingOnStartup(boolean enabled)
Should named queries be checked on startup?- Parameters:
enabled
-true
indicates that they should;false
indicates they should not.- Returns:
this
, for method chaining- See Also:
AvailableSettings.QUERY_STARTUP_CHECKING
-
applySecondLevelCacheSupport
SessionFactoryBuilder applySecondLevelCacheSupport(boolean enabled)
Should second level caching support be enabled?- 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:
AvailableSettings.USE_SECOND_LEVEL_CACHE
-
applyQueryCacheSupport
SessionFactoryBuilder applyQueryCacheSupport(boolean enabled)
Should second level query caching support be enabled?- 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:
AvailableSettings.USE_QUERY_CACHE
-
applyTimestampsCacheFactory
SessionFactoryBuilder applyTimestampsCacheFactory(TimestampsCacheFactory factory)
Specifies a QueryCacheFactory to use for building query cache handlers.- Parameters:
factory
- The QueryCacheFactory to use- Returns:
this
, for method chaining- See Also:
AvailableSettings.QUERY_CACHE_FACTORY
-
applyCacheRegionPrefix
SessionFactoryBuilder applyCacheRegionPrefix(java.lang.String prefix)
Apply a prefix to prepended to all cache region names for this SessionFactory.- Parameters:
prefix
- The prefix.- Returns:
this
, for method chaining- See Also:
AvailableSettings.CACHE_REGION_PREFIX
-
applyMinimalPutsForCaching
SessionFactoryBuilder applyMinimalPutsForCaching(boolean enabled)
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 its is very rare that users need to set this, generally speaking.- 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:
AvailableSettings.USE_MINIMAL_PUTS
,RegionFactory.isMinimalPutsEnabledByDefault()
-
applyStructuredCacheEntries
SessionFactoryBuilder applyStructuredCacheEntries(boolean enabled)
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.- Parameters:
enabled
-true
indicates that structured cache entries (human readable) should be used;false
indicates that the native entry structure should be used.- Returns:
this
, for method chaining- See Also:
AvailableSettings.USE_STRUCTURED_CACHE
-
applyDirectReferenceCaching
SessionFactoryBuilder applyDirectReferenceCaching(boolean enabled)
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.- 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:
AvailableSettings.USE_DIRECT_REFERENCE_CACHE_ENTRIES
-
applyAutomaticEvictionOfCollectionCaches
SessionFactoryBuilder applyAutomaticEvictionOfCollectionCaches(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). 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.- Parameters:
enabled
-true
indicates that these collection caches should be evicted automatically.- Returns:
this
, for method chaining- See Also:
AvailableSettings.AUTO_EVICT_COLLECTION_CACHE
-
applyJdbcBatchSize
SessionFactoryBuilder applyJdbcBatchSize(int size)
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.- Parameters:
size
- The batch size to use.- Returns:
this
, for method chaining- See Also:
AvailableSettings.STATEMENT_BATCH_SIZE
-
applyJdbcBatchingForVersionedEntities
SessionFactoryBuilder applyJdbcBatchingForVersionedEntities(boolean enabled)
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.- Parameters:
enabled
- The batch size to use.- Returns:
this
, for method chaining- See Also:
AvailableSettings.BATCH_VERSIONED_DATA
-
applyScrollableResultsSupport
SessionFactoryBuilder 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. Also, needed if user is supplying connections (and so no Connection is available when we bootstrap).- Parameters:
enabled
-true
to enable this support,false
to disable it- Returns:
this
, for method chaining- See Also:
AvailableSettings.USE_SCROLLABLE_RESULTSET
-
applyResultSetsWrapping
SessionFactoryBuilder applyResultSetsWrapping(boolean enabled)
Hibernate 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.- Parameters:
enabled
-true
indicates Hibernate should wrap result sets;false
indicates it should not.- Returns:
this
, for method chaining- See Also:
AvailableSettings.WRAP_RESULT_SETS
-
applyGetGeneratedKeysSupport
SessionFactoryBuilder applyGetGeneratedKeysSupport(boolean enabled)
Should JDBCStatement.getGeneratedKeys()
feature be used for retrieval of *insert-generated* ids?- Parameters:
enabled
-true
indicates we should use JDBC getGeneratedKeys support;false
indicates we should not.- Returns:
this
, for method chaining- See Also:
AvailableSettings.USE_GET_GENERATED_KEYS
-
applyJdbcFetchSize
SessionFactoryBuilder applyJdbcFetchSize(int size)
Apply a fetch size to the JDBC driver for fetching results.- Parameters:
size
- The fetch saize to be passed to the driver.- Returns:
this
, for method chaining- See Also:
AvailableSettings.USE_GET_GENERATED_KEYS
,Statement.setFetchSize(int)
-
applyConnectionHandlingMode
SessionFactoryBuilder applyConnectionHandlingMode(PhysicalConnectionHandlingMode connectionHandlingMode)
Apply the specified handling mode for JDBC connections- Parameters:
connectionHandlingMode
- The handling mode to apply- Returns:
this
, for method chaining- See Also:
AvailableSettings.ACQUIRE_CONNECTIONS
,AvailableSettings.RELEASE_CONNECTIONS
,ConnectionAcquisitionMode
,ConnectionReleaseMode
-
applyConnectionReleaseMode
@Deprecated SessionFactoryBuilder applyConnectionReleaseMode(ConnectionReleaseMode connectionReleaseMode)
Deprecated.Apply a ConnectionReleaseMode.- Parameters:
connectionReleaseMode
- The ConnectionReleaseMode to use.- Returns:
this
, for method chaining- See Also:
AvailableSettings.RELEASE_CONNECTIONS
-
applyConnectionProviderDisablesAutoCommit
default SessionFactoryBuilder applyConnectionProviderDisablesAutoCommit(boolean providerDisablesAutoCommit)
-
applySqlComments
SessionFactoryBuilder applySqlComments(boolean enabled)
Should Hibernate apply comments to SQL it generates?- Parameters:
enabled
-true
indicates comments should be applied;false
indicates not.- Returns:
this
, for method chaining- See Also:
AvailableSettings.USE_SQL_COMMENTS
-
applySqlFunction
SessionFactoryBuilder applySqlFunction(java.lang.String registrationName, SQLFunction sqlFunction)
Apply a SQLFunction to the underlyingSQLFunctionRegistry
. TODO : Ultimately I would like this to move toMetadataBuilder
in conjunction with allowing mappings to reference SQLFunctions. today mappings can only name SQL functions directly, not through the SQLFunctionRegistry indirection- Parameters:
registrationName
- The name to register it under.sqlFunction
- The SQLFunction impl- Returns:
this
, for method chaining
-
allowOutOfTransactionUpdateOperations
SessionFactoryBuilder allowOutOfTransactionUpdateOperations(boolean allow)
-
enableReleaseResourcesOnCloseEnabled
SessionFactoryBuilder enableReleaseResourcesOnCloseEnabled(boolean enable)
Should resources held byEntityManager
instance be released immediately on close? The other option is to release them as part of an after-transaction callback.
-
enableJpaQueryCompliance
SessionFactoryBuilder enableJpaQueryCompliance(boolean enabled)
-
enableJpaTransactionCompliance
SessionFactoryBuilder enableJpaTransactionCompliance(boolean enabled)
-
enableJpaListCompliance
SessionFactoryBuilder enableJpaListCompliance(boolean enabled)
-
enableJpaClosedCompliance
SessionFactoryBuilder enableJpaClosedCompliance(boolean enabled)
-
unwrap
<T extends SessionFactoryBuilder> T unwrap(java.lang.Class<T> type)
Allows unwrapping this builder as another, more specific type.- Type Parameters:
T
-- Parameters:
type
-- Returns:
- The unwrapped builder.
-
build
SessionFactory build()
After all options have been set, build the SessionFactory.- Returns:
- The built SessionFactory.
-
-