public class LocalSessionFactoryBuilder
extends Configuration
A Spring-provided extension of the standard Hibernate Configuration class,
adding SpringSessionContext as a default and providing convenient ways
to specify a JDBC DataSource and an application class loader.
This is designed for programmatic use, e.g. in @Bean factory methods;
consider using LocalSessionFactoryBean for XML bean definition files.
Typically combined with HibernateTransactionManager for declarative
transactions against the SessionFactory and its JDBC DataSource.
Compatible with Hibernate 5.0/5.1 as well as 5.2/5.3, as of Spring 5.1.
Set up with Hibernate 5.2/5.3, this builder is also a convenient way to set up
a JPA EntityManagerFactory since the Hibernate SessionFactory
natively exposes the JPA EntityManagerFactory interface as well now.
This builder supports Hibernate 5.3 BeanContainer integration,
MetadataSources from custom BootstrapServiceRegistryBuilder
setup, as well as other advanced Hibernate configuration options beyond the
standard JPA bootstrap contract.
Set the Spring JtaTransactionManager or the JTA TransactionManager
to be used with Hibernate, if any. Allows for using a Spring-managed transaction
manager for Hibernate 5's session and cache synchronization, with the
"hibernate.transaction.jta.platform" automatically set to it.
A passed-in Spring JtaTransactionManager needs to contain a JTA
TransactionManager reference to be usable here, except for the WebSphere
case where we'll automatically set WebSphereExtendedJtaPlatform accordingly.
Note: If this is set, the Hibernate settings should not contain a JTA platform
setting to avoid meaningless double configuration.
Specify custom type filters for Spring-based scanning for entity classes.
Default is to search all specified packages for classes annotated with
@javax.persistence.Entity, @javax.persistence.Embeddable
or @javax.persistence.MappedSuperclass.
Build the Hibernate SessionFactory through background bootstrapping,
using the given executor for a parallel initialization phase
(e.g. a SimpleAsyncTaskExecutor).
SessionFactory initialization will then switch into background
bootstrap mode, with a SessionFactory proxy immediately returned for
injection purposes instead of waiting for Hibernate's bootstrapping to complete.
However, note that the first actual call to a SessionFactory method will
then block until Hibernate's bootstrapping completed, if not ready by then.
For maximum benefit, make sure to avoid early SessionFactory calls
in init methods of related beans, even for metadata introspection purposes.