jakub.petr
jakub.petr

Reputation: 3031

Get EntityManager from Hibernate session

I have built my application on Hibernate, but now I need to get EntityManager for one third-party module.

Could you please give me some hints how to get JPA objects from Hibernate?

(in my case I have SessionFactory and need EntityManager)

Upvotes: 11

Views: 21073

Answers (1)

SSB
SSB

Reputation: 789

I found this in Hibernate 5.2

 Session session = HibernateUtil.getSessionFactory().openSession();
 EntityManager em = session.getEntityManagerFactory().createEntityManager();

Upvotes: 15

Related Questions