Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LocalSessionFactoryBean and HibernateTransactionManager for JPA EntityManagerFactory setup [SPR-17002] #21540

Closed
spring-projects-issues opened this issue Jul 3, 2018 · 1 comment
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jul 3, 2018

Juergen Hoeller opened SPR-17002 and commented

As outlined in #21494 and #21454, it is desirable for the Hibernate LocalSessionFactoryBean to be usable for JPA EntityManagerFactory setup as well: that is, in a first-class fashion with out-of-the-box integration with other JPA facilities such as @PersistenceContext injection, making it a replacement for LocalContainerEntityManagerFactoryBean for Hibernate JPA setup purposes. The same goes for HibernateTransactionManager which should work fine as a replacement for JpaTransactionManager in such a scenario, just with stronger Hibernate-specific behavior.


Issue Links:

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Jul 4, 2018

Juergen Hoeller commented

SessionHolder extends EntityManagerHolder now, allowing for @PersistenceContext and co to interact with HibernateTransactionManager's thread-bound transactions, and SpringSessionContext (backing SessionFactory.getCurrentSession()) is capable of interacting with JpaTransactionManager by detecting a plain EntityManagerHolder as well.

This covers a lot of ground for a start: With Hibernate 5.2 and 5.3, LocalSessionFactoryBean and HibernateTransactionManager serve as a 99%-compatible replacement for LocalContainerEntityManagerFactoryBean and JpaTransactionManager in many scenarios, allowing for interaction with SessionFactory.getCurrentSession() (and also HibernateTemplate) next to @PersistenceContext EntityManager interaction within the same local transaction (#21454). That aside, such a setup also provides stronger Hibernate integration (#21494, #20852) and more configuration flexibility, not being constrained by JPA bootstrap contracts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants