Class LocalSessionFactoryBean

java.lang.Object
org.springframework.orm.hibernate5.HibernateExceptionTranslator
org.springframework.orm.hibernate5.LocalSessionFactoryBean
All Implemented Interfaces:
Aware, BeanFactoryAware, DisposableBean, FactoryBean<SessionFactory>, InitializingBean, ResourceLoaderAware, PersistenceExceptionTranslator

FactoryBean that creates a Hibernate SessionFactory. This is the usual way to set up a shared Hibernate SessionFactory in a Spring application context; the SessionFactory can then be passed to data access objects via dependency injection.

Compatible with Hibernate ORM 5.5/5.6, as of Spring Framework 6.0. This Hibernate-specific LocalSessionFactoryBean can be an immediate alternative to LocalContainerEntityManagerFactoryBean for common JPA purposes: The Hibernate SessionFactory will natively expose the JPA EntityManagerFactory interface as well, and Hibernate BeanContainer integration will be registered out of the box. In combination with HibernateTransactionManager, this naturally allows for mixing JPA access code with native Hibernate access code within the same transaction.

Since:
4.2
Author:
Juergen Hoeller
See Also: