Skip to content

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

Closed

Description

@spring-projects-issues

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:

Activity

  1. spring-projects-issues commented on Jul 4, 2018

    @spring-projects-issues
    CollaboratorAuthor

    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.

  2. added
    in: data
    type: enhancement
    on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: datatype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions