JPA EntityManager get Session Object in Hibernate

How to get Session object from JPA EntityManager


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

Steps:


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


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


Hibernate Create Update Delete child objects - Best way

Hibernate Create Update Delete child objects - Best way