Interface SessionFactoryOptions
- All Superinterfaces:
QueryEngineOptions
- All Known Implementing Classes:
AbstractDelegatingSessionFactoryOptions
SessionFactory.- Since:
- 5.0
- See Also:
- API Note:
- This is an SPI contract. Access it by unwrapping a
SessionFactorytoSessionFactoryImplementorand callingSessionFactoryImplementor.getSessionFactoryOptions(). The legacy SPI accessorSessionFactory.getSessionFactoryOptions()is deprecated and marked for removal; the accessor onSessionFactoryImplementorremains supported.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether to process Jakarta Persistence entity lifecycle callbacks.Build an array of baselineSessionEventListeners.booleanDo newly-obtained JDBC connections come with autocommit already disabled?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.Describes how an interceptor was configured, without resolving any CDI or managed beans.Obtain a reference to the current tenant identifier resolver, if any, or returnnullis there is no resolver configured.A custom strategy for determining if an entity instance is dirty.intThe default batch size for batch fetching in new sessions.default StringThe 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 StringThe 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.default CheckHandlingThe graph parser mode to use for parsing entity graph strings.The default initialCacheModefor new sessions.The default initialFlushModefor new sessions.intThe 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 booleanintintintintintThe layout of entries in the query cache.intThe number ofQueryStatisticsentries that should be stored byStatistics.The service registry to use in building the factory.The name to be used for theSessionFactory.Observers for events raised by the factory.The defaultStatementInspectorfor this factory.The StatementObserver, if one, applied to this SessionFactory.Obtain a reference to the current tenant credentials mapper, which is used to obtain the database user and password for the current tenant each time a connection is obtained.Obtain a reference to the current tenant schema mapper, which is used to set the schema to the schema belonging to the current tenant each time a connection is obtained.A factory for theTimestampsCacheused 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 booleanbooleanbooleanbooleanbooleanIs flush-time bidirectional association management enabled?booleanShould Hibernate validate that non-optional attributes have non-null values?default booleanbooleanShould explanatory comment text be added to the generated SQL?default booleandefault booleandefault booleanisDirectJavaTimeJdbcAccessEnabled(Class<?> javaTimeType) Determines whether direct JDBC access using the exact Java Time class is enabled by configuration and supported by the Dialect and JDBC driver.booleanbooleanbooleanbooleanbooleanShould generated identifiers be reset after entity removal?booleanAre detached proxies and collections fetched in a temporary persistence context?booleanWas building of theSessionFactoryinitiated through JPA bootstrapping, or through Hibernate-native bootstrapping?booleanbooleanbooleanShould we avoid overwriting cache entries with identical entries?booleanIs there a multi-tenant connection provider configured?booleanAre named queries validated when the factory is created?booleanbooleanbooleanbooleanDeprecated.booleanShould native queries return JDBC datetime types instead of usingjava.timetypes.booleanbooleanbooleanbooleanIs the query cache enabled?booleanbooleanIs the second-level cache enabled?Is the session factory name also a JNDI name, indicating we should bind it into JNDI?booleanIs collection of statistics enabled by default for this factory?booleanAre second-level cache entries stored in a human-readable format.booleanIs subselect fetching enabled by default in new sessions?booleanbooleanControls whether Hibernate should try to map named parameter names specified in aProcedureCallorStoredProcedureQueryto named parameters in the JDBCCallableStatement.booleanWhether to use the legacy format for serializing/deserializing XML data.voidsetCheckNullability(boolean enabled) Allows Bean Validation to disable null checking.Methods inherited from interface QueryEngineOptions
allowImmutableEntityUpdate, getCriteriaValueHandlingMode, getCustomHqlTranslator, getCustomSqlFunctionMap, getCustomSqmFunctionRegistry, getCustomSqmMultiTableInsertStrategy, getCustomSqmMultiTableMutationStrategy, getCustomSqmTranslatorFactory, getImmutableEntityUpdateQueryHandlingMode, isPortableIntegerDivisionEnabled, isSafeModeEnabled, resolveCustomSqmMultiTableInsertStrategy, resolveCustomSqmMultiTableMutationStrategy
-
Method Details
-
getUuid
Get the UUID unique to this SessionFactoryOptions. Will be the same value available asSessionFactoryImplementor.getUuid().- Specified by:
getUuidin interfaceQueryEngineOptions- Returns:
- The UUID for this SessionFactory.
- See Also:
- API Note:
- The value is generated as a
UUID, but kept as a String.
-
getServiceRegistry
The service registry to use in building the factory.- Returns:
- The service registry to use.
-
getBeanManagerReference
-
getValidatorFactoryReference
-
getJpaCompliance
- Specified by:
getJpaCompliancein interfaceQueryEngineOptions- See Also:
-
isJpaBootstrap
boolean isJpaBootstrap()Was building of theSessionFactoryinitiated through JPA bootstrapping, or through Hibernate-native bootstrapping?- Returns:
trueindicates the SessionFactory was built through JPA bootstrapping;falseindicates it was built through native bootstrapping.
-
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:
getSessionFactoryNamein interfaceQueryEngineOptions- Returns:
- The session factory name, or
nullif none was specified - See Also:
-
isSessionFactoryNameAlsoJndiName
Is the session factory name also a JNDI name, indicating we should bind it into JNDI?- Returns:
trueif the SessionFactory name is also a JNDI name;falseotherwise.- See Also:
-
isStatisticsEnabled
boolean isStatisticsEnabled()Is collection of statistics enabled by default for this factory?- See Also:
-
getConfiguredInterceptor
Describes how an interceptor was configured, without resolving any CDI or managed beans.- Since:
- 8.0
-
getStatementObserver
The StatementObserver, if one, applied to this SessionFactory.- See Also:
-
getStatementInspector
The defaultStatementInspectorfor this factory.- See Also:
-
getSessionFactoryObservers
Observers for events raised by the factory.- See Also:
-
buildSessionEventListeners
Build an array of baselineSessionEventListeners.- Since:
- 7.0
- See Also:
-
isIdentifierRollbackEnabled
boolean isIdentifierRollbackEnabled()Should generated identifiers be reset after entity removal?- See Also:
-
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.
-
isBidirectionalAssociationManagementEnabled
boolean isBidirectionalAssociationManagementEnabled()Is flush-time bidirectional association management enabled?- See Also:
-
getDefaultBatchFetchSize
int getDefaultBatchFetchSize()The default batch size for batch fetching in new sessions.- See Also:
-
getMaximumFetchDepth
-
isSubselectFetchEnabled
boolean isSubselectFetchEnabled()Is subselect fetching enabled by default in new sessions?- See Also:
-
getDefaultNullPrecedence
The default precedence of null values in sorted query results.- See Also:
-
isOrderUpdatesEnabled
boolean isOrderUpdatesEnabled()- See Also:
-
isOrderInsertsEnabled
boolean isOrderInsertsEnabled()- See Also:
-
isMultiTenancyEnabled
-
getCurrentTenantIdentifierResolver
Obtain a reference to the current tenant identifier resolver, if any, or returnnullis there is no resolver configured.- See Also:
-
getTenantSchemaMapper
Obtain a reference to the current tenant schema mapper, which is used to set the schema to the schema belonging to the current tenant each time a connection is obtained.- Since:
- 7.1
- See Also:
-
getTenantCredentialsMapper
Obtain a reference to the current tenant credentials mapper, which is used to obtain the database user and password for the current tenant each time a connection is obtained.- Since:
- 7.3
- See Also:
-
isJtaTrackByThread
boolean isJtaTrackByThread()- See Also:
-
isNamedQueryStartupCheckingEnabled
boolean isNamedQueryStartupCheckingEnabled()Are named queries validated when the factory is created?- See Also:
-
isSecondLevelCacheEnabled
-
isQueryCacheEnabled
-
getQueryCacheLayout
The layout of entries in the query cache.- See Also:
-
getTimestampsCacheFactory
A factory for theTimestampsCacheused to track invalidation of cached query result sets. May benullwhen caching is disabled.- See Also:
-
getCacheRegionPrefix
-
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()- See Also:
-
isAutoEvictCollectionCache
boolean isAutoEvictCollectionCache()- See Also:
-
getJdbcBatchSize
int getJdbcBatchSize()The default JDBC statement batch size for new sessions.- See Also:
-
isScrollableResultSetsEnabled
boolean isScrollableResultSetsEnabled()- See Also:
-
isGetGeneratedKeysEnabled
boolean isGetGeneratedKeysEnabled()- See Also:
-
getJdbcFetchSize
-
getPhysicalConnectionHandlingMode
- See Also:
-
doesConnectionProviderDisableAutoCommit
boolean doesConnectionProviderDisableAutoCommit()Do newly-obtained JDBC connections come with autocommit already disabled?- See Also:
-
isCommentsEnabled
boolean isCommentsEnabled()Should explanatory comment text be added to the generated SQL?- See Also:
-
getCustomEntityDirtinessStrategy
A custom strategy for determining if an entity instance is dirty.- See Also:
-
getEntityNameResolvers
An array of custom entity name resolvers.- See Also:
-
getEntityNotFoundDelegate
Get the delegate for handling entity-not-found exception conditions.Returns
StandardEntityNotFoundDelegateby default.- Returns:
- The specific
EntityNotFoundDelegateto use - See Also:
-
isFlushBeforeCompletionEnabled
boolean isFlushBeforeCompletionEnabled()- See Also:
-
isAutoCloseSessionEnabled
boolean isAutoCloseSessionEnabled()- See Also:
-
isJtaTransactionAccessEnabled
boolean isJtaTransactionAccessEnabled()- See Also:
-
isPreferUserTransaction
boolean isPreferUserTransaction()- See Also:
-
isAllowOutOfTransactionUpdateOperations
boolean isAllowOutOfTransactionUpdateOperations()- See Also:
-
getJdbcTimeZone
-
getTemporalTableStrategy
- See Also:
-
getAuditStrategy
- See Also:
-
isCriteriaCopyTreeEnabled
default boolean isCriteriaCopyTreeEnabled()- See Also:
-
isCriteriaPlanCacheEnabled
default boolean isCriteriaPlanCacheEnabled()- See Also:
-
getNativeJdbcParametersIgnored
default boolean getNativeJdbcParametersIgnored()- See Also:
-
getFinalPersistentFieldsHandling
- Since:
- 8.0
- See Also:
-
isFailOnPaginationOverCollectionFetchEnabled
boolean isFailOnPaginationOverCollectionFetchEnabled()- See Also:
-
getDefaultCatalog
-
getDefaultSchema
-
inClauseParameterPaddingEnabled
default boolean inClauseParameterPaddingEnabled()- See Also:
-
getQueryStatisticsMaxSize
int getQueryStatisticsMaxSize()The number ofQueryStatisticsentries that should be stored byStatistics.- See Also:
-
areJPACallbacksEnabled
boolean areJPACallbacksEnabled()Whether to process Jakarta Persistence entity lifecycle callbacks.- See Also:
-
isUseOfJdbcNamedParametersEnabled
boolean isUseOfJdbcNamedParametersEnabled()Controls whether Hibernate should try to map named parameter names specified in aProcedureCallorStoredProcedureQueryto 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 tofalsesimply circumvents that check and always performs positional binding.- Returns:
trueindicates we should try to useCallableStatementnamed parameters, if the Dialect says it is supported;falseindicates that we should never try to useCallableStatementnamed parameters, regardless of what the Dialect says.- See Also:
-
isCollectionsInDefaultFetchGroupEnabled
default boolean isCollectionsInDefaultFetchGroupEnabled() -
isUnownedAssociationTransientCheck
boolean isUnownedAssociationTransientCheck()- See Also:
-
getPreferredSqlTypeCodeForBoolean
- See Also:
-
getPreferredSqlTypeCodeForDuration
- See Also:
-
getPreferredSqlTypeCodeForUuid
- See Also:
-
getPreferredSqlTypeCodeForInstant
- See Also:
-
getPreferredSqlTypeCodeForArray
- See Also:
-
getDefaultTimeZoneStorageStrategy
- See Also:
-
isDirectJavaTimeJdbcAccessEnabled
Determines whether direct JDBC access using the exact Java Time class is enabled by configuration and supported by the Dialect and JDBC driver.- Parameters:
javaTimeType- the exact Java class to be used at the JDBC boundary- Since:
- 8.0
- See Also:
-
isPreferJavaTimeJdbcTypesEnabled
Deprecated.UseisDirectJavaTimeJdbcAccessEnabled(Class)when determining whether direct JDBC access should be used for a Java Time type.Returns the resolved value of "hibernate.type.java_time_use_direct_jdbc", after configuration conversion and defaulting, but before accounting for Dialect or JDBC-driver capabilities.Code selecting a JDBC mapping should instead use
isDirectJavaTimeJdbcAccessEnabled(Class). -
isPreferNativeEnumTypesEnabled
boolean isPreferNativeEnumTypesEnabled()- See Also:
-
isPreferLocaleLanguageTagEnabled
boolean isPreferLocaleLanguageTagEnabled()- 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()- See Also:
-
isPreferJdbcDatetimeTypesInNativeQueriesEnabled
boolean isPreferJdbcDatetimeTypesInNativeQueriesEnabled()Should native queries return JDBC datetime types instead of usingjava.timetypes.- Since:
- 7.0
- See Also:
-
getCacheStoreMode
Determine the defaultCacheStoreMode, given the current session properties.- Parameters:
properties- the Session properties, ornullto use the factory defaults- Returns:
- either the
CacheStoreModeas defined in the session-specific properties, or the factory default whenpropertiesisnull. Returnsnullif neither the Jakarta nor legacy property is set.
-
getCacheRetrieveMode
Determine the defaultCacheRetrieveMode, given the current session properties.- Parameters:
properties- the Session properties, ornullto use the factory defaults- Returns:
- either the
CacheRetrieveModeas defined in the session-specific properties, or the factory default whenpropertiesisnull. Returnsnullif neither the Jakarta nor legacy property is set.
-
getInitialSessionCacheMode
-
getInitialSessionFlushMode
-
getDefaultLockOptions
-
getDefaultSessionProperties
-
getGraphParserMode
The graph parser mode to use for parsing entity graph strings.- Since:
- 7.0
- See Also:
-
isDirectJavaTimeJdbcAccessEnabled(Class)when determining whether direct JDBC access should be used for a Java Time type.