JPA EntityManager get Session Object in Hibernate

How to get Session object from JPA EntityManager

With Hibernate (JPA 2.0 implementation), you would do:


//1. Inject/Autowire Entity Manager
private EntityManager entityManager;    //javax.persistence.EntityManager 

//2. Get Session Object 
Session session = entityManager.unwrap(Session.class);  //org.hibernate.Session

No comments :

Post a Comment

Your Comment and Question will help to make this blog better...