Simultaneous use of Hibernate and Spring data jpa?

后端 未结 3 1861
孤独总比滥情好
孤独总比滥情好 2021-01-31 03:33

Is it possible to use Spring Data JPA (backed by Hibernate as JPA provider) and directly use Hibernate at the same time?

The problem is that when i use JpaTransactionMan

3条回答
  •  被撕碎了的回忆
    2021-01-31 04:03

    Instead of creating a SessionFactory, use EntityManager.unwrap(Session.class) to get a Hibernate Session and retrieve the session factory from the Session object.

    You can also use EntityManagerFactory.unwrap(SessionFactory.class) to get the Hibernate SessionFactory directly.

提交回复
热议问题