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 type: enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues 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:

  • #20850 Support for Hibernate ORM 5.3
  • #20852 Support Hibernate 5.3's ManagedBeanRegistry for dependency injection
  • #21454 Session from SessionFactory.getCurrentSession not synchronized with current JPA transaction on Hibernate 5.2
  • #19024 Hibernate5 LocalSessionFactoryBean does not translate javax.persistence exceptions
  • #21494 Propagate read-only status to Hibernate Session through setDefaultReadOnly
  • #21724 Mention asynchronous JPA bootstrapping in the reference documentation
  • #21749 HibernateTransactionManager should lazily acquire JDBC Connection (like HibernateJpaDialect)
  • #21553 HibernateJpaDialect cannot translate JDBCException to custom DataAccessException
@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues 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.

@spring-projects-issues spring-projects-issues added in: data type: enhancement labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 5.1 RC1 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants