Top Description Methods
org.hibernate.boot

public Interface SessionFactoryBuilder

Known Direct Subinterfaces
org.hibernate.boot.spi.SessionFactoryBuilderImplementor
Known Direct Implementers
org.hibernate.boot.spi.AbstractDelegatingSessionFactoryBuilder
Annotations
@SuppressWarnings:UnusedReturnValue
Imports
java.util.Map, java.util.function.Supplier, org.hibernate.ConnectionReleaseMode, .CustomEntityDirtinessStrategy, .EntityMode, .EntityNameResolver, .Interceptor, .MultiTenancyStrategy, .NullPrecedence, .SessionFactory, .SessionFactoryObserver, org.hibernate.cache.spi.TimestampsCacheFactory, org.hibernate.context.spi.CurrentTenantIdentifierResolver, org.hibernate.dialect.function.SQLFunction, org.hibernate.hql.spi.id.MultiTableBulkIdStrategy, org.hibernate.jpa.spi.JpaCompliance, org.hibernate.loader.BatchFetchStyle, org.hibernate.proxy.EntityNotFoundDelegate, org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode, .StatementInspector, org.hibernate.tuple.entity.EntityTuplizer, .EntityTuplizerFactory

The contract for building a org.hibernate.SessionFactory given a number of options.
Authors
Steve Ebersole, Gail Badner
Since
5.0

Method Summary

Modifier and TypeMethod and Description
public SessionFactoryBuilder

Returns:

this, for method chaining
addEntityNameResolver
(EntityNameResolver...
The entityNameResolvers to add
entityNameResolvers
)

Specifies one or more entity name resolvers to be applied to the SessionFactory (see the org.hibernate.EntityNameResolver contract for more information..

public SessionFactoryBuilder

Returns:

this, for method chaining
addSessionFactoryObservers
(SessionFactoryObserver...
The observers to add
observers
)

Specifies one or more observers to be applied to the SessionFactory.

public SessionFactoryBuilder
public SessionFactoryBuilder

Returns:

this, for method chaining
applyAutoClosing
(boolean
true indicates they should be auto-closed; false indicates not.
enabled
)

Applies whether Sessions should be automatically closed at the end of the transaction.

public SessionFactoryBuilder

Returns:

this, for method chaining
applyAutoFlushing
(boolean
true indicates they should be auto-flushed; false indicates not.
enabled
)

Applies whether Sessions should be automatically flushed at the end of the transaction.

public SessionFactoryBuilder

Returns:

this, for method chaining
applyAutomaticEvictionOfCollectionCaches
(boolean
true indicates that these collection caches should be evicted automatically.
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).

public SessionFactoryBuilder

Returns:

this, for method chaining
applyBatchFetchStyle
(BatchFetchStyle
The style to use
style
)

What style of batching should be used?

public SessionFactoryBuilder

Returns:

this, for method chaining
applyBeanManager
(Object
The CDI BeanManager to use
beanManager
)

Apply a CDI BeanManager to the SessionFactory being built.

public SessionFactoryBuilder

Returns:

this, for method chaining
applyCacheRegionPrefix
(String
The prefix.
prefix
)

Apply a prefix to prepended to all cache region names for this SessionFactory.

public SessionFactoryBuilder

Returns:

this, for method chaining
applyConnectionHandlingMode
(PhysicalConnectionHandlingMode
The handling mode to apply
connectionHandlingMode
)

Apply the specified handling mode for JDBC connections

public default SessionFactoryBuilder
applyConnectionProviderDisablesAutoCommit(boolean providerDisablesAutoCommit)

public SessionFactoryBuilder

Returns:

this, for method chaining
applyConnectionReleaseMode
(ConnectionReleaseMode
The ConnectionReleaseMode to use.
connectionReleaseMode
)

Deprecated Use applyConnectionHandlingMode instead
Apply a ConnectionReleaseMode.
public SessionFactoryBuilder

Returns:

this, for method chaining
applyCurrentTenantIdentifierResolver
(CurrentTenantIdentifierResolver
The resolution strategy to use.
resolver
)

Specifies a strategy for resolving the notion of a "current" tenant-identifier when using multi-tenancy together with current sessions

public SessionFactoryBuilder

Returns:

this, for method chaining
applyCustomEntityDirtinessStrategy
(CustomEntityDirtinessStrategy
The custom strategy to be used.
strategy
)

Specifies a custom entity dirtiness strategy to be applied to the SessionFactory.

public SessionFactoryBuilder

Returns:

this, for method chaining
applyDefaultBatchFetchSize
(int
The size to use for batch fetching for entities/collections which do not specify an explicit batch fetch size.
size
)

Allows specifying a default batch-fetch size for all entities and collections which do not otherwise specify a batch-fetch size.

public SessionFactoryBuilder

Returns:

this, for method chaining
applyDefaultEntityMode
(EntityMode
The default entity mode to use.
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.
public SessionFactoryBuilder

Returns:

this, for method chaining
applyDefaultNullPrecedence
(NullPrecedence
The default null precedence to use.
nullPrecedence
)

Apply a null precedence (NULLS FIRST, NULLS LAST) to be applied order-by clauses rendered into SQL queries.

public SessionFactoryBuilder
applyDelayedEntityLoaderCreations(boolean delay)

Should entity Loaders be generated immediately?

public SessionFactoryBuilder

Returns:

this, for method chaining
applyDirectReferenceCaching
(boolean
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.
enabled
)

Generally, Hibernate will extract the information from an entity and put that extracted information into the second-level cache.

public SessionFactoryBuilder

Returns:

this, for method chaining
applyEntityNotFoundDelegate
(EntityNotFoundDelegate
The delegate/strategy to use.
entityNotFoundDelegate
)

Names the org.hibernate.proxy.EntityNotFoundDelegate to be applied to the SessionFactory.

public SessionFactoryBuilder

Returns:

this, for method chaining
applyEntityTuplizer
(EntityMode
The entity mode that which this tuplizer will be applied.
entityMode
,
Class<? extends EntityTuplizer>
The custom tuplizer class.
tuplizerClass
)

Register the default org.hibernate.tuple.entity.EntityTuplizer to be applied to the SessionFactory.

public SessionFactoryBuilder

Returns:

this, for method chaining
applyEntityTuplizerFactory
(EntityTuplizerFactory
The EntityTuplizerFactory to use.
entityTuplizerFactory
)

Specify the EntityTuplizerFactory to use.

public SessionFactoryBuilder

Returns:

this, for method chaining
applyGetGeneratedKeysSupport
(boolean
true indicates we should use JDBC getGeneratedKeys support; false indicates we should not.
enabled
)

Should JDBC java.sql.PreparedStatement#getGeneratedKeys() feature be used for retrieval of *insert-generated* ids?

public SessionFactoryBuilder

Returns:

this, for method chaining
applyIdentifierRollbackSupport
(boolean
true indicates identifiers should be unset; false indicates not.
enabled
)

Should generated identifiers be "unset" on entities during a rollback?

public SessionFactoryBuilder

Returns:

this, for method chaining
applyInterceptor
(Interceptor
The 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 org.hibernate.SessionBuilder#interceptor

public SessionFactoryBuilder

Returns:

this, for method chaining
applyJdbcBatchingForVersionedEntities
(boolean
The batch size to use.
enabled
)

This setting controls whether versioned entities will be included in JDBC batching.

public SessionFactoryBuilder

Returns:

this, for method chaining
applyJdbcBatchSize
(int
The batch size to use.
size
)

Specifies the maximum number of statements to batch together in a JDBC batch for insert, update and delete operations.

public SessionFactoryBuilder

Returns:

this, for method chaining
applyJdbcFetchSize
(int
The fetch size to be passed to the driver.
size
)

Apply a fetch size to the JDBC driver for fetching results.

public SessionFactoryBuilder

Returns:

this, for method chaining
applyJtaTrackingByThread
(boolean
true indicates we should track by thread; false indicates not
enabled
)

If using the built-in Hibernate JTA-based TransactionCoordinator/Builder, should it track JTA transactions by thread in an attempt to detect timeouts?

public SessionFactoryBuilder

Returns:

this, for method chaining
applyLazyInitializationOutsideTransaction
(boolean
true indicates initialization outside the transaction should be allowed; false indicates it should not.
enabled
)

Should the application be allowed to initialize uninitialized lazy state outside the bounds of a transaction?

public SessionFactoryBuilder

Returns:

this, for method chaining
applyMaximumFetchDepth
(int
The depth for limiting joins.
depth
)

Apply a limit to the depth Hibernate will use for outer joins.

public SessionFactoryBuilder

Returns:

this, for method chaining
applyMinimalPutsForCaching
(boolean
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.
enabled
)

By default, Hibernate will always just push data into the cache without first checking if that data already exists.

public SessionFactoryBuilder

Returns:

this, for method chaining
applyMultiTableBulkIdStrategy
(MultiTableBulkIdStrategy
The strategy for handling multi-table updates and deletes.
strategy
)

How should updates and deletes that span multiple tables be handled?

public SessionFactoryBuilder

Returns:

this, for method chaining
applyMultiTenancyStrategy
(MultiTenancyStrategy
The form of multi-tenancy in use.
strategy
)

Apply the form of multi-tenancy used by the application

public SessionFactoryBuilder

Returns:

this, for method chaining
applyName
(String
The name to use for the SessionFactory being built
sessionFactoryName
)

Applies a SessionFactory name.

public SessionFactoryBuilder

Returns:

this, for method chaining
applyNameAsJndiName
(boolean
true indicates that the name specified in applyName will be used for binding the SessionFactory into JNDI.
isJndiName
)

Applies a SessionFactory name.

public SessionFactoryBuilder

Returns:

this, for method chaining
applyNamedQueryCheckingOnStartup
(boolean
true indicates that they should; false indicates they should not.
enabled
)

Should named queries be checked on startup?

public SessionFactoryBuilder

Returns:

this, for method chaining
applyNullabilityChecking
(boolean
true indicates that Hibernate should perform nullness checking; false indicates it should not.
enabled
)

Should attributes using columns marked as not-null be checked (by Hibernate) for nullness?

public SessionFactoryBuilder

Returns:

this, for method chaining
applyOrderingOfInserts
(boolean
true indicates that ordering should be enabled; false indicates not
enabled
)

Apply whether ordering of inserts should be enabled.

public SessionFactoryBuilder

Returns:

this, for method chaining
applyOrderingOfUpdates
(boolean
true indicates that ordering should be enabled; false indicates not
enabled
)

Apply whether ordering of updates should be enabled.

public SessionFactoryBuilder

Returns:

this, for method chaining
applyPreferUserTransactions
(boolean
true indicates we should prefer javax.transaction.UserTransaction; false indicates we should prefer javax.transaction.Transaction
preferUserTransactions
)

If using the built-in Hibernate JTA-based TransactionCoordinator/Builder, should it prefer to use javax.transaction.UserTransaction over javax.transaction.Transaction?

public SessionFactoryBuilder

Returns:

this, for method chaining
applyQueryCacheSupport
(boolean
true indicates we should enable the use of second level query caching; false indicates we should disable the use of second level query caching.
enabled
)

Should second level query caching support be enabled?

public SessionFactoryBuilder

Returns:

this, for method chaining
applyQuerySubstitutions
(Map<K, V>
The substitution map
substitutions
)

Deprecated This is a legacy feature and should never be needed anymore...
Apply query substitutions to use in HQL queries.
public SessionFactoryBuilder

Returns:

this, for method chaining
applyResultSetsWrapping
(boolean
true indicates Hibernate should wrap result sets; false indicates it should not.
enabled
)

Hibernate currently accesses results from the JDBC ResultSet by name.

public SessionFactoryBuilder

Returns:

this, for method chaining
applyScrollableResultsSupport
(boolean
true to enable this support, false to disable it
enabled
)

Should scrollable results be supported in queries?

public SessionFactoryBuilder

Returns:

this, for method chaining
applySecondLevelCacheSupport
(boolean
true indicates we should enable the use of second level caching; false indicates we should disable the use of second level caching.
enabled
)

Should second level caching support be enabled?

public SessionFactoryBuilder

Returns:

this, for method chaining
applySqlComments
(boolean
true indicates comments should be applied; false indicates not.
enabled
)

Should Hibernate apply comments to SQL it generates?

public SessionFactoryBuilder

Returns:

this, for method chaining
applySqlFunction
(String
The name to register it under.
registrationName
,
SQLFunction
The SQLFunction impl
sqlFunction
)

Apply a SQLFunction to the underlying org.hibernate.dialect.function.SQLFunctionRegistry.

public SessionFactoryBuilder

Returns:

this, for method chaining
applyStatelessInterceptor
(Class<? extends Interceptor>
The interceptor class
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 in org.hibernate.SessionBuilder#interceptor

public SessionFactoryBuilder

Returns:

this, for method chaining
applyStatelessInterceptor
(Supplier<? extends Interceptor>
Supplier instance which is used to retrieve the interceptor
statelessInterceptorSupplier
)

Names a Supplier 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 in org.hibernate.SessionBuilder#interceptor

public SessionFactoryBuilder

Returns:

this, for method chaining
applyStatementInspector
(StatementInspector
The 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 org.hibernate.SessionBuilder#statementInspector

public SessionFactoryBuilder

Returns:

this, for method chaining
applyStatisticsSupport
(boolean
true indicates that statistics gathering should be enabled; false indicates not.
enabled
)

Applies whether statistics gathering is enabled.

public SessionFactoryBuilder

Returns:

this, for method chaining
applyStrictJpaQueryLanguageCompliance
(boolean
true indicates that we should strictly adhere to the JPQL subset; false indicates we should accept the broader HQL syntax.
enabled
)

Deprecated Use enableJpaQueryCompliance instead
Should we strictly adhere to JPA Query Language (JPQL) syntax, or more broadly support all of Hibernate's superset (HQL)?
public SessionFactoryBuilder

Returns:

this, for method chaining
applyStructuredCacheEntries
(boolean
true indicates that structured cache entries (human readable) should be used; false indicates that the native entry structure should be used.
enabled
)

By default, Hibernate stores data in the cache in its own optimized format.

public SessionFactoryBuilder
public SessionFactoryBuilder

Returns:

this, for method chaining
applyTimestampsCacheFactory
(TimestampsCacheFactory
The QueryCacheFactory to use
factory
)

Specifies a QueryCacheFactory to use for building query cache handlers.

public SessionFactoryBuilder

Returns:

this, for method chaining
applyValidatorFactory
(Object
The Bean Validation ValidatorFactory to use
validatorFactory
)

Apply a Bean Validation ValidatorFactory to the SessionFactory being built.

public SessionFactory

Returns:

The built SessionFactory.
build
()

Deprecated as a consequence of SessionFactory being deprecated.
After all options have been set, build the SessionFactory.
public SessionFactoryBuilder
enableJpaClosedCompliance(boolean enabled)

public SessionFactoryBuilder
enableJpaListCompliance(boolean enabled)

public SessionFactoryBuilder
enableJpaQueryCompliance(boolean enabled)

public SessionFactoryBuilder
public SessionFactoryBuilder
enableReleaseResourcesOnCloseEnabled(boolean enable)

Should resources held by javax.persistence.EntityManager instance be released immediately on close?

public <T extends SessionFactoryBuilder> T

Returns:

The unwrapped builder.
unwrap
(Class<T> type)

Allows unwrapping this builder as another, more specific type.