Package org.hibernate.boot.spi
Interface SessionFactoryOptions
- All Superinterfaces:
QueryEngineOptions
- All Known Implementing Classes:
AbstractDelegatingSessionFactoryOptions
,SessionFactoryOptionsBuilder
Aggregator of special options used to build the
SessionFactory
.- Since:
- 5.0
- See Also:
- API Note:
- This type belongs to an SPI package. Due to a historical mistake, it is exposed
via the deprecated method
SessionFactory.getSessionFactoryOptions()
.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Should JPA entity lifecycle callbacks be processed by theEventEngine
andCallbackRegistry
?default SessionEventListener[]
Build an array of baselineSessionEventListener
s.boolean
Do newly-obtained JDBC connections come with autocommit already disabled?Deprecated, for removal: This API element is subject to removal in a future version.This operation is a layer-breaker, exposing an internal type.A factory-specific prefix to be applied to all cache region names.getCacheRetrieveMode
(Map<String, Object> properties) Determine the defaultCacheRetrieveMode
, given the current session properties.getCacheStoreMode
(Map<String, Object> properties) Determine the defaultCacheStoreMode
, given the current session properties.Obtain a reference to the current tenant identifier resolver, if any, or returnnull
is there is no resolver configured.A custom strategy for determining if an entity instance is dirty.int
The default batch size for batch fetching in new sessions.default String
The default catalog to use in generated SQL when a catalog wasn't specified in the mapping, neither explicitly nor implicitly (see the concept of implicit catalog in XML mapping).The default lock scope and lock timeout.The default precedence of null values in sorted query results.default String
The default schema to use in generated SQL when a catalog wasn't specified in the mapping, neither explicitly nor implicitly (see the concept of implicit schema in XML mapping).Default properties for brand-new sessions.The default tenant identifier java type to use, in case no explicit tenant identifier property is defined.An array of custom entity name resolvers.Get the delegate for handling entity-not-found exception conditions.The default initialCacheMode
for new sessions.The default initialFlushMode
for new sessions.An interceptor instance shared between all sessions created by this factory.int
The default JDBC statement batch size for new sessions.The timezone to use when interacting with JDBC.The format mapper to use for serializing/deserializing JSON data.default boolean
int
int
int
int
int
The layout of entries in the query cache.int
The number ofQueryStatistics
entries that should be stored byStatistics
.Deprecated, for removal: This API element is subject to removal in a future version.This is unused and will be removed.The service registry to use in building the factory.The name to be used for theSessionFactory
.Observers for events raised by the factory.Supplier<? extends Interceptor>
A statelessSupplier
for interceptor instances which are not shared between sessions created by this factory.The defaultStatementInspector
for this factory.Deprecated, for removal: This API element is subject to removal in a future version.A factory for theTimestampsCache
used to track invalidation of cached query result sets.getUuid()
Get the UUID unique to this SessionFactoryOptions.The format mapper to use for serializing/deserializing XML data.default boolean
boolean
default boolean
Deprecated, for removal: This API element is subject to removal in a future version.with no replacement.boolean
boolean
boolean
Should Hibernate validate that non-optional attributes have non-null values?default boolean
boolean
Should explanatory comment text be added to the generated SQL?default boolean
default boolean
boolean
Deprecated, for removal: This API element is subject to removal in a future version.This is no longer usedboolean
boolean
boolean
boolean
boolean
Should generated identifiers be reset after entity removal?boolean
Are detached proxies and collections fetched in a temporary persistence context?boolean
Was building of theSessionFactory
initiated through JPA bootstrapping, or through Hibernate-native bootstrapping?boolean
boolean
boolean
Should we avoid overwriting cache entries with identical entries?boolean
Is there a multi-tenant connection provider configured?boolean
Are named queries validated when the factory is created?boolean
boolean
boolean
boolean
boolean
Should native queries return JDBC datetime types instead of usingjava.time
types.boolean
boolean
boolean
Is the query cache enabled?boolean
Deprecated, for removal: This API element is subject to removal in a future version.since "hibernate.discard_pc_on_close" is deprecatedboolean
boolean
Is the second-level cache enabled?Is the session factory name also a JNDI name, indicating we should bind it into JNDI?boolean
Is collection of statistics enabled by default for this factory?boolean
Are second-level cache entries stored in a human-readable format.boolean
Is subselect fetching enabled by default in new sessions?boolean
boolean
Controls whether Hibernate should try to map named parameter names specified in aProcedureCall
orStoredProcedureQuery
to named parameters in the JDBCCallableStatement
.boolean
Whether to use the legacy format for serializing/deserializing XML data.void
setCheckNullability
(boolean enabled) Allows Bean Validation to disable null checking.Methods inherited from interface org.hibernate.query.spi.QueryEngineOptions
allowImmutableEntityUpdate, getCriteriaValueHandlingMode, getCustomHqlTranslator, getCustomSqlFunctionMap, getCustomSqmFunctionRegistry, getCustomSqmMultiTableInsertStrategy, getCustomSqmMultiTableMutationStrategy, getCustomSqmTranslatorFactory, getImmutableEntityUpdateQueryHandlingMode, isJsonFunctionsEnabled, isPortableIntegerDivisionEnabled, isXmlFunctionsEnabled
-
Method Details
-
getUuid
String getUuid()Get the UUID unique to this SessionFactoryOptions. Will be the same value available asSessionFactoryImplementor.getUuid()
.- Specified by:
getUuid
in interfaceQueryEngineOptions
- Returns:
- The UUID for this SessionFactory.
- See Also:
- API Note:
- The value is generated as a
UUID
, but kept as a String.
-
getServiceRegistry
StandardServiceRegistry getServiceRegistry()The service registry to use in building the factory.- Returns:
- The service registry to use.
-
getBeanManagerReference
Object getBeanManagerReference() -
getValidatorFactoryReference
Object getValidatorFactoryReference() -
getJpaCompliance
JpaCompliance getJpaCompliance()- Specified by:
getJpaCompliance
in interfaceQueryEngineOptions
- See Also:
-
isJpaBootstrap
boolean isJpaBootstrap()Was building of theSessionFactory
initiated through JPA bootstrapping, or through Hibernate-native bootstrapping?- Returns:
true
indicates the SessionFactory was built through JPA bootstrapping;false
indicates it was built through native bootstrapping.
-
isAllowRefreshDetachedEntity
Deprecated, for removal: This API element is subject to removal in a future version.with no replacement. -
getSessionFactoryName
String getSessionFactoryName()The name to be used for theSessionFactory
. This is used during in-VM serialization; seeSessionFactoryRegistry
. May also be used as a JNDI name, depending on "hibernate.session_factory_jndi_name" and "hibernate.session_factory_name_is_jndi".- Specified by:
getSessionFactoryName
in interfaceQueryEngineOptions
- Returns:
- The session factory name
- See Also:
-
isSessionFactoryNameAlsoJndiName
Boolean isSessionFactoryNameAlsoJndiName()Is the session factory name also a JNDI name, indicating we should bind it into JNDI?- Returns:
true
if the SessionFactory name is also a JNDI name;false
otherwise.- See Also:
-
isStatisticsEnabled
boolean isStatisticsEnabled()Is collection of statistics enabled by default for this factory? -
getInterceptor
Interceptor getInterceptor()An interceptor instance shared between all sessions created by this factory. Such an interceptor must be thread-safe and may not hold state associated with any given session.- Returns:
- The interceptor instance to use factory-wide by default. May be
null
. - See Also:
-
getStatelessInterceptorImplementorSupplier
Supplier<? extends Interceptor> getStatelessInterceptorImplementorSupplier()A statelessSupplier
for interceptor instances which are not shared between sessions created by this factory. This allows eachInterceptor
instances itself to hold state associated with its session.- Returns:
- The interceptor supplier to use by default. May be
null
. - See Also:
-
getStatementInspector
StatementInspector getStatementInspector()The defaultStatementInspector
for this factory. -
getSessionFactoryObservers
SessionFactoryObserver[] getSessionFactoryObservers()Observers for events raised by the factory. -
getBaselineSessionEventsListenerBuilder
@Deprecated(since="7.0", forRemoval=true) BaselineSessionEventsListenerBuilder getBaselineSessionEventsListenerBuilder()Deprecated, for removal: This API element is subject to removal in a future version.This operation is a layer-breaker, exposing an internal type. It will be removed. UsebuildSessionEventListeners()
instead. -
buildSessionEventListeners
Build an array of baselineSessionEventListener
s.- Since:
- 7.0
- See Also:
-
isIdentifierRollbackEnabled
boolean isIdentifierRollbackEnabled()Should generated identifiers be reset after entity removal? -
isCheckNullability
boolean isCheckNullability()Should Hibernate validate that non-optional attributes have non-null values?- See Also:
-
setCheckNullability
Allows Bean Validation to disable null checking.- API Note:
- It's quite ugly to have a setter method on this SPI. This operation is for internal use by Bean Validation integration logic.
-
isInitializeLazyStateOutsideTransactionsEnabled
boolean isInitializeLazyStateOutsideTransactionsEnabled()Are detached proxies and collections fetched in a temporary persistence context?- See Also:
- API Note:
- The naming here is very misleading. This behavior has little to do with transactions.
-
getTempTableDdlTransactionHandling
@Deprecated(since="7.0", forRemoval=true) TempTableDdlTransactionHandling getTempTableDdlTransactionHandling()Deprecated, for removal: This API element is subject to removal in a future version.This is unused and will be removed. -
isDelayBatchFetchLoaderCreationsEnabled
Deprecated, for removal: This API element is subject to removal in a future version.This is no longer used -
getDefaultBatchFetchSize
int getDefaultBatchFetchSize()The default batch size for batch fetching in new sessions. -
getMaximumFetchDepth
Integer getMaximumFetchDepth()- See Also:
-
isSubselectFetchEnabled
boolean isSubselectFetchEnabled()Is subselect fetching enabled by default in new sessions? -
getDefaultNullPrecedence
Nulls getDefaultNullPrecedence()The default precedence of null values in sorted query results.- See Also:
-
isOrderUpdatesEnabled
boolean isOrderUpdatesEnabled()- See Also:
-
isOrderInsertsEnabled
boolean isOrderInsertsEnabled()- See Also:
-
isMultiTenancyEnabled
boolean isMultiTenancyEnabled()Is there a multi-tenant connection provider configured? -
getCurrentTenantIdentifierResolver
CurrentTenantIdentifierResolver<Object> getCurrentTenantIdentifierResolver()Obtain a reference to the current tenant identifier resolver, if any, or returnnull
is there is no resolver configured. -
isJtaTrackByThread
boolean isJtaTrackByThread()- See Also:
-
isNamedQueryStartupCheckingEnabled
boolean isNamedQueryStartupCheckingEnabled()Are named queries validated when the factory is created?- See Also:
-
isSecondLevelCacheEnabled
boolean isSecondLevelCacheEnabled()Is the second-level cache enabled?- See Also:
-
isQueryCacheEnabled
boolean isQueryCacheEnabled()Is the query cache enabled?- See Also:
-
getQueryCacheLayout
The layout of entries in the query cache.- See Also:
-
getTimestampsCacheFactory
TimestampsCacheFactory getTimestampsCacheFactory()A factory for theTimestampsCache
used to track invalidation of cached query result sets.- See Also:
-
getCacheRegionPrefix
String getCacheRegionPrefix()A factory-specific prefix to be applied to all cache region names.- See Also:
-
isMinimalPutsEnabled
boolean isMinimalPutsEnabled()Should we avoid overwriting cache entries with identical entries?This is useful if cache writes are much more expensive than cache reads.
- See Also:
- API Note:
- This is currently unused.
-
isStructuredCacheEntriesEnabled
boolean isStructuredCacheEntriesEnabled()Are second-level cache entries stored in a human-readable format.- See Also:
-
isDirectReferenceCacheEntriesEnabled
boolean isDirectReferenceCacheEntriesEnabled() -
isAutoEvictCollectionCache
boolean isAutoEvictCollectionCache() -
getSchemaAutoTooling
Deprecated, for removal: This API element is subject to removal in a future version.This is unused and will be removed.- See Also:
-
getJdbcBatchSize
int getJdbcBatchSize()The default JDBC statement batch size for new sessions. -
isScrollableResultSetsEnabled
boolean isScrollableResultSetsEnabled()- See Also:
-
isGetGeneratedKeysEnabled
boolean isGetGeneratedKeysEnabled()- See Also:
-
getJdbcFetchSize
Integer getJdbcFetchSize()- See Also:
-
getPhysicalConnectionHandlingMode
PhysicalConnectionHandlingMode getPhysicalConnectionHandlingMode() -
doesConnectionProviderDisableAutoCommit
boolean doesConnectionProviderDisableAutoCommit()Do newly-obtained JDBC connections come with autocommit already disabled? -
isCommentsEnabled
boolean isCommentsEnabled()Should explanatory comment text be added to the generated SQL?- See Also:
-
getCustomEntityDirtinessStrategy
CustomEntityDirtinessStrategy getCustomEntityDirtinessStrategy()A custom strategy for determining if an entity instance is dirty. -
getEntityNameResolvers
EntityNameResolver[] getEntityNameResolvers()An array of custom entity name resolvers. -
getEntityNotFoundDelegate
EntityNotFoundDelegate getEntityNotFoundDelegate()Get the delegate for handling entity-not-found exception conditions.Returns
StandardEntityNotFoundDelegate
by default.- Returns:
- The specific
EntityNotFoundDelegate
to use, may benull
- See Also:
-
isFlushBeforeCompletionEnabled
boolean isFlushBeforeCompletionEnabled() -
isAutoCloseSessionEnabled
boolean isAutoCloseSessionEnabled()- See Also:
-
isJtaTransactionAccessEnabled
boolean isJtaTransactionAccessEnabled() -
isPreferUserTransaction
boolean isPreferUserTransaction() -
isAllowOutOfTransactionUpdateOperations
boolean isAllowOutOfTransactionUpdateOperations() -
isReleaseResourcesOnCloseEnabled
Deprecated, for removal: This API element is subject to removal in a future version.since "hibernate.discard_pc_on_close" is deprecated- See Also:
-
getJdbcTimeZone
TimeZone getJdbcTimeZone()The timezone to use when interacting with JDBC. -
isCriteriaCopyTreeEnabled
default boolean isCriteriaCopyTreeEnabled()- See Also:
-
isCriteriaPlanCacheEnabled
default boolean isCriteriaPlanCacheEnabled() -
getNativeJdbcParametersIgnored
default boolean getNativeJdbcParametersIgnored() -
isFailOnPaginationOverCollectionFetchEnabled
boolean isFailOnPaginationOverCollectionFetchEnabled() -
getDefaultCatalog
The default catalog to use in generated SQL when a catalog wasn't specified in the mapping, neither explicitly nor implicitly (see the concept of implicit catalog in XML mapping).- Returns:
- The default catalog to use.
- See Also:
-
getDefaultSchema
The default schema to use in generated SQL when a catalog wasn't specified in the mapping, neither explicitly nor implicitly (see the concept of implicit schema in XML mapping).- Returns:
- The default schema to use.
- See Also:
-
inClauseParameterPaddingEnabled
default boolean inClauseParameterPaddingEnabled() -
getQueryStatisticsMaxSize
int getQueryStatisticsMaxSize()The number ofQueryStatistics
entries that should be stored byStatistics
. -
areJPACallbacksEnabled
boolean areJPACallbacksEnabled()Should JPA entity lifecycle callbacks be processed by theEventEngine
andCallbackRegistry
? -
isUseOfJdbcNamedParametersEnabled
boolean isUseOfJdbcNamedParametersEnabled()Controls whether Hibernate should try to map named parameter names specified in aProcedureCall
orStoredProcedureQuery
to named parameters in the JDBCCallableStatement
.As JPA is defined, the use of named parameters is essentially of dubious value since by spec the parameters have to be defined in the order they are defined in the procedure/function declaration - we can always bind them positionally. The whole idea of named parameters for CallableStatement is the ability to bind these in any order, but since we unequivocally know the order anyway binding them via name really gains nothing.
If this is
true
, we still need to make sure the Dialect supports named binding. Setting this tofalse
simply circumvents that check and always performs positional binding.- Returns:
true
indicates we should try to useCallableStatement
named parameters, if the Dialect says it is supported;false
indicates that we should never try to useCallableStatement
named parameters, regardless of what the Dialect says.- See Also:
-
isCollectionsInDefaultFetchGroupEnabled
default boolean isCollectionsInDefaultFetchGroupEnabled() -
isUnownedAssociationTransientCheck
boolean isUnownedAssociationTransientCheck() -
getPreferredSqlTypeCodeForBoolean
-
getPreferredSqlTypeCodeForDuration
-
getPreferredSqlTypeCodeForUuid
- See Also:
-
getPreferredSqlTypeCodeForInstant
-
getPreferredSqlTypeCodeForArray
-
getDefaultTimeZoneStorageStrategy
- See Also:
-
isPreferJavaTimeJdbcTypesEnabled
boolean isPreferJavaTimeJdbcTypesEnabled() -
isPreferNativeEnumTypesEnabled
boolean isPreferNativeEnumTypesEnabled()- See Also:
-
getJsonFormatMapper
The format mapper to use for serializing/deserializing JSON data.- Since:
- 6.0
- See Also:
-
getXmlFormatMapper
The format mapper to use for serializing/deserializing XML data.- Since:
- 6.0.1
- See Also:
-
isXmlFormatMapperLegacyFormatEnabled
Whether to use the legacy format for serializing/deserializing XML data.- Since:
- 7.0
- See Also:
-
getDefaultTenantIdentifierJavaType
The default tenant identifier java type to use, in case no explicit tenant identifier property is defined.- Since:
- 6.4
-
isPassProcedureParameterNames
boolean isPassProcedureParameterNames() -
isPreferJdbcDatetimeTypesInNativeQueriesEnabled
boolean isPreferJdbcDatetimeTypesInNativeQueriesEnabled()Should native queries return JDBC datetime types instead of usingjava.time
types.- Since:
- 7.0
- See Also:
-
getCacheStoreMode
Determine the defaultCacheStoreMode
, given the current session properties.- Parameters:
properties
- the Session properties- Returns:
- either the
CacheStoreMode
as defined in the session-specific properties, or as defined in the properties shared across all sessions (the defaults).
-
getCacheRetrieveMode
Determine the defaultCacheRetrieveMode
, given the current session properties.- Parameters:
properties
- the Session properties- Returns:
- either the
CacheRetrieveMode
as defined in the session-specific properties, or as defined in the properties shared across all sessions (the defaults).
-
getInitialSessionCacheMode
CacheMode getInitialSessionCacheMode()The default initialCacheMode
for new sessions. -
getInitialSessionFlushMode
FlushMode getInitialSessionFlushMode()The default initialFlushMode
for new sessions. -
getDefaultLockOptions
LockOptions getDefaultLockOptions()The default lock scope and lock timeout. -
getDefaultSessionProperties
Default properties for brand-new sessions.- See Also:
-