public interface SessionFactoryBuilder
SessionFactory
given a number of options.Modifier and Type | Method and Description |
---|---|
SessionFactoryBuilder |
addEntityNameResolver(EntityNameResolver... entityNameResolvers)
Specifies one or more entity name resolvers to be applied to the SessionFactory (see the
EntityNameResolver
contract for more information.. |
SessionFactoryBuilder |
addSessionFactoryObservers(SessionFactoryObserver... observers)
Specifies one or more observers to be applied to the SessionFactory.
|
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(Object beanManager)
Apply a CDI BeanManager to the SessionFactory being built.
|
SessionFactoryBuilder |
applyCacheRegionPrefix(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 connections
|
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 sessions
|
SessionFactoryBuilder |
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 |
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 the
EntityNotFoundDelegate to be applied to the SessionFactory. |
SessionFactoryBuilder |
applyEntityTuplizer(EntityMode entityMode,
Class<? extends EntityTuplizer> tuplizerClass)
Register the default
EntityTuplizer to be applied to the SessionFactory. |
SessionFactoryBuilder |
applyEntityTuplizerFactory(EntityTuplizerFactory entityTuplizerFactory)
Specify the EntityTuplizerFactory to use.
|
SessionFactoryBuilder |
applyGetGeneratedKeysSupport(boolean enabled)
Should JDBC
Statement.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 in
SessionBuilder.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 application
|
SessionFactoryBuilder |
applyName(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 use
UserTransaction over Transaction ? |
SessionFactoryBuilder |
applyQueryCacheFactory(QueryCacheFactory factory)
Specifies a QueryCacheFactory to use for building query cache handlers.
|
SessionFactoryBuilder |
applyQueryCacheSupport(boolean enabled)
Should second level query caching support be enabled?
|
SessionFactoryBuilder |
applyQuerySubstitutions(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(String registrationName,
SQLFunction sqlFunction)
Apply a SQLFunction to the underlying
SQLFunctionRegistry . |
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 in
SessionBuilder.statementInspector(org.hibernate.resource.jdbc.spi.StatementInspector) |
SessionFactoryBuilder |
applyStatisticsSupport(boolean enabled)
Applies whether statistics gathering is enabled.
|
SessionFactoryBuilder |
applyStrictJpaQueryLanguageCompliance(boolean enabled)
Should we strictly adhere to JPA Query Language (JPQL) syntax, or more broadly support
all of Hibernate's superset (HQL)?
Setting this to
true may cause valid HQL to throw an exception because it violates
the JPQL subset. |
SessionFactoryBuilder |
applyStructuredCacheEntries(boolean enabled)
By default, Hibernate stores data in the cache in its own optimized format.
|
SessionFactoryBuilder |
applyTempTableDdlTransactionHandling(TempTableDdlTransactionHandling handling) |
SessionFactoryBuilder |
applyValidatorFactory(Object validatorFactory)
Apply a Bean Validation ValidatorFactory to the SessionFactory being built.
|
SessionFactory |
build()
After all options have been set, build the SessionFactory.
|
<T extends SessionFactoryBuilder> |
unwrap(Class<T> type)
Allows unwrapping this builder as another, more specific type.
|
SessionFactoryBuilder applyValidatorFactory(Object validatorFactory)
validatorFactory
- The Bean Validation ValidatorFactory to usethis
, for method chainingSessionFactoryBuilder applyBeanManager(Object beanManager)
beanManager
- The CDI BeanManager to usethis
, for method chainingSessionFactoryBuilder applyName(String sessionFactoryName)
sessionFactoryName
- The name to use for the SessionFactory being builtthis
, for method chainingAvailableSettings.SESSION_FACTORY_NAME
SessionFactoryBuilder applyNameAsJndiName(boolean isJndiName)
isJndiName
- true
indicates that the name specified in
applyName(java.lang.String)
will be used for binding the SessionFactory into JNDI.this
, for method chainingAvailableSettings.SESSION_FACTORY_NAME_IS_JNDI
SessionFactoryBuilder applyAutoClosing(boolean enabled)
enabled
- true
indicates they should be auto-closed; false
indicates not.this
, for method chainingAvailableSettings.AUTO_CLOSE_SESSION
SessionFactoryBuilder applyAutoFlushing(boolean enabled)
enabled
- true
indicates they should be auto-flushed; false
indicates not.this
, for method chainingAvailableSettings.FLUSH_BEFORE_COMPLETION
SessionFactoryBuilder applyStatisticsSupport(boolean enabled)
enabled
- true
indicates that statistics gathering should be enabled; false
indicates not.this
, for method chainingAvailableSettings.GENERATE_STATISTICS
SessionFactoryBuilder applyInterceptor(Interceptor interceptor)
SessionBuilder.interceptor(org.hibernate.Interceptor)
interceptor
- The interceptorthis
, for method chainingAvailableSettings.INTERCEPTOR
SessionFactoryBuilder applyStatementInspector(StatementInspector statementInspector)
SessionBuilder.statementInspector(org.hibernate.resource.jdbc.spi.StatementInspector)
statementInspector
- The StatementInspectorthis
, for method chainingAvailableSettings.STATEMENT_INSPECTOR
SessionFactoryBuilder addSessionFactoryObservers(SessionFactoryObserver... observers)
observers
- The observers to addthis
, for method chainingSessionFactoryBuilder applyCustomEntityDirtinessStrategy(CustomEntityDirtinessStrategy strategy)
CustomEntityDirtinessStrategy
for details.strategy
- The custom strategy to be used.this
, for method chainingAvailableSettings.CUSTOM_ENTITY_DIRTINESS_STRATEGY
SessionFactoryBuilder addEntityNameResolver(EntityNameResolver... entityNameResolvers)
EntityNameResolver
contract for more information.. Can be called multiple times to add additional resolvers..entityNameResolvers
- The entityNameResolvers to addthis
, for method chainingSessionFactoryBuilder applyEntityNotFoundDelegate(EntityNotFoundDelegate entityNotFoundDelegate)
EntityNotFoundDelegate
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.entityNotFoundDelegate
- The delegate/strategy to use.this
, for method chainingSessionFactoryBuilder applyIdentifierRollbackSupport(boolean enabled)
enabled
- true
indicates identifiers should be unset; false
indicates not.this
, for method chainingAvailableSettings.USE_IDENTIFIER_ROLLBACK
@Deprecated SessionFactoryBuilder applyDefaultEntityMode(EntityMode entityMode)
entityMode
- The default entity mode to use.this
, for method chainingAvailableSettings.DEFAULT_ENTITY_MODE
SessionFactoryBuilder applyNullabilityChecking(boolean enabled)
enabled
- true
indicates that Hibernate should perform nullness checking; false
indicates
it should not.this
, for method chainingAvailableSettings.CHECK_NULLABILITY
SessionFactoryBuilder applyLazyInitializationOutsideTransaction(boolean enabled)
enabled
- true
indicates initialization outside the transaction should be allowed; false
indicates it should not.this
, for method chainingAvailableSettings.ENABLE_LAZY_LOAD_NO_TRANS
SessionFactoryBuilder applyEntityTuplizerFactory(EntityTuplizerFactory entityTuplizerFactory)
entityTuplizerFactory
- The EntityTuplizerFactory to use.this
, for method chainingSessionFactoryBuilder applyEntityTuplizer(EntityMode entityMode, Class<? extends EntityTuplizer> tuplizerClass)
EntityTuplizer
to be applied to the SessionFactory.entityMode
- The entity mode that which this tuplizer will be applied.tuplizerClass
- The custom tuplizer class.this
, for method chainingSessionFactoryBuilder applyMultiTableBulkIdStrategy(MultiTableBulkIdStrategy strategy)
strategy
- The strategy for handling multi-table updates and deletes.this
, for method chainingAvailableSettings.HQL_BULK_ID_STRATEGY
SessionFactoryBuilder applyTempTableDdlTransactionHandling(TempTableDdlTransactionHandling handling)
SessionFactoryBuilder applyBatchFetchStyle(BatchFetchStyle style)
style
- The style to usethis
, for method chainingAvailableSettings.BATCH_FETCH_STYLE
SessionFactoryBuilder applyDefaultBatchFetchSize(int size)
size
- The size to use for batch fetching for entities/collections which
do not specify an explicit batch fetch size.this
, for method chainingAvailableSettings.DEFAULT_BATCH_FETCH_SIZE
SessionFactoryBuilder applyMaximumFetchDepth(int depth)
depth
- The depth for limiting joins.this
, for method chainingAvailableSettings.MAX_FETCH_DEPTH
SessionFactoryBuilder applyDefaultNullPrecedence(NullPrecedence nullPrecedence)
nullPrecedence
- The default null precedence to use.this
, for method chainingAvailableSettings.DEFAULT_NULL_ORDERING
SessionFactoryBuilder applyOrderingOfInserts(boolean enabled)
enabled
- true
indicates that ordering should be enabled; false
indicates notthis
, for method chainingAvailableSettings.ORDER_INSERTS
SessionFactoryBuilder applyOrderingOfUpdates(boolean enabled)
enabled
- true
indicates that ordering should be enabled; false
indicates notthis
, for method chainingAvailableSettings.ORDER_UPDATES
SessionFactoryBuilder applyMultiTenancyStrategy(MultiTenancyStrategy strategy)
strategy
- The form of multi-tenancy in use.this
, for method chainingAvailableSettings.MULTI_TENANT
SessionFactoryBuilder applyCurrentTenantIdentifierResolver(CurrentTenantIdentifierResolver resolver)
resolver
- The resolution strategy to use.this
, for method chainingAvailableSettings.MULTI_TENANT_IDENTIFIER_RESOLVER
SessionFactoryBuilder applyJtaTrackingByThread(boolean enabled)
enabled
- true
indicates we should track by thread; false
indicates notthis
, for method chainingAvailableSettings.JTA_TRACK_BY_THREAD
SessionFactoryBuilder applyPreferUserTransactions(boolean preferUserTransactions)
UserTransaction
over Transaction
?preferUserTransactions
- true
indicates we should prefer UserTransaction
;
false
indicates we should prefer Transaction
this
, for method chainingAvailableSettings.PREFER_USER_TRANSACTION
@Deprecated SessionFactoryBuilder applyQuerySubstitutions(Map substitutions)
substitutions
- The substitution mapthis
, for method chainingAvailableSettings.QUERY_SUBSTITUTIONS
SessionFactoryBuilder applyStrictJpaQueryLanguageCompliance(boolean enabled)
true
may cause valid HQL to throw an exception because it violates
the JPQL subset.enabled
- true
indicates that we should strictly adhere to the JPQL subset; false
indicates we should accept the broader HQL syntax.this
, for method chainingAvailableSettings.JPAQL_STRICT_COMPLIANCE
SessionFactoryBuilder applyNamedQueryCheckingOnStartup(boolean enabled)
enabled
- true
indicates that they should; false
indicates they should not.this
, for method chainingAvailableSettings.QUERY_STARTUP_CHECKING
SessionFactoryBuilder applySecondLevelCacheSupport(boolean enabled)
enabled
- true
indicates we should enable the use of second level caching; false
indicates we should disable the use of second level caching.this
, for method chainingAvailableSettings.USE_SECOND_LEVEL_CACHE
SessionFactoryBuilder applyQueryCacheSupport(boolean enabled)
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.this
, for method chainingAvailableSettings.USE_QUERY_CACHE
SessionFactoryBuilder applyQueryCacheFactory(QueryCacheFactory factory)
factory
- The QueryCacheFactory to usethis
, for method chainingAvailableSettings.QUERY_CACHE_FACTORY
SessionFactoryBuilder applyCacheRegionPrefix(String prefix)
prefix
- The prefix.this
, for method chainingAvailableSettings.CACHE_REGION_PREFIX
SessionFactoryBuilder applyMinimalPutsForCaching(boolean enabled)
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.this
, for method chainingAvailableSettings.USE_MINIMAL_PUTS
,
RegionFactory.isMinimalPutsEnabledByDefault()
SessionFactoryBuilder applyStructuredCacheEntries(boolean enabled)
enabled
- true
indicates that structured cache entries (human readable) should be used;
false
indicates that the native entry structure should be used.this
, for method chainingAvailableSettings.USE_STRUCTURED_CACHE
SessionFactoryBuilder applyDirectReferenceCaching(boolean enabled)
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.this
, for method chainingAvailableSettings.USE_DIRECT_REFERENCE_CACHE_ENTRIES
SessionFactoryBuilder applyAutomaticEvictionOfCollectionCaches(boolean enabled)
enabled
- true
indicates that these collection caches should be evicted automatically.this
, for method chainingAvailableSettings.AUTO_EVICT_COLLECTION_CACHE
SessionFactoryBuilder applyJdbcBatchSize(int size)
size
- The batch size to use.this
, for method chainingAvailableSettings.STATEMENT_BATCH_SIZE
SessionFactoryBuilder applyJdbcBatchingForVersionedEntities(boolean enabled)
false
by default.enabled
- The batch size to use.this
, for method chainingAvailableSettings.BATCH_VERSIONED_DATA
SessionFactoryBuilder applyScrollableResultsSupport(boolean enabled)
enabled
- true
to enable this support, false
to disable itthis
, for method chainingAvailableSettings.USE_SCROLLABLE_RESULTSET
SessionFactoryBuilder applyResultSetsWrapping(boolean enabled)
enabled
- true
indicates Hibernate should wrap result sets; false
indicates
it should not.this
, for method chainingAvailableSettings.WRAP_RESULT_SETS
SessionFactoryBuilder applyGetGeneratedKeysSupport(boolean enabled)
Statement.getGeneratedKeys()
feature be used for
retrieval of *insert-generated* ids?enabled
- true
indicates we should use JDBC getGeneratedKeys support; false
indicates we should not.this
, for method chainingAvailableSettings.USE_GET_GENERATED_KEYS
SessionFactoryBuilder applyJdbcFetchSize(int size)
size
- The fetch saize to be passed to the driver.this
, for method chainingAvailableSettings.USE_GET_GENERATED_KEYS
,
Statement.setFetchSize(int)
SessionFactoryBuilder applyConnectionHandlingMode(PhysicalConnectionHandlingMode connectionHandlingMode)
connectionHandlingMode
- The handling mode to applythis
, for method chainingAvailableSettings.ACQUIRE_CONNECTIONS
,
AvailableSettings.RELEASE_CONNECTIONS
,
ConnectionAcquisitionMode
,
ConnectionReleaseMode
@Deprecated SessionFactoryBuilder applyConnectionReleaseMode(ConnectionReleaseMode connectionReleaseMode)
applyConnectionHandlingMode(org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode)
insteadconnectionReleaseMode
- The ConnectionReleaseMode to use.this
, for method chainingAvailableSettings.RELEASE_CONNECTIONS
SessionFactoryBuilder applySqlComments(boolean enabled)
enabled
- true
indicates comments should be applied; false
indicates not.this
, for method chainingAvailableSettings.USE_SQL_COMMENTS
SessionFactoryBuilder applySqlFunction(String registrationName, SQLFunction sqlFunction)
SQLFunctionRegistry
.
TODO : Ultimately I would like this to move to MetadataBuilder
in conjunction with allowing mappings to reference SQLFunctions.
today mappings can only name SQL functions directly, not through the SQLFunctionRegistry indirectionregistrationName
- The name to register it under.sqlFunction
- The SQLFunction implthis
, for method chaining<T extends SessionFactoryBuilder> T unwrap(Class<T> type)
T
- type
- SessionFactory build()
Copyright © 2017 JBoss by Red Hat. All rights reserved.