I have code that looks like this.
this.entityManager = AppFactory.instance().getEntityManagerFactory().createEntityManager();
this.hibernateSession = entityManager.unwrap(Session.class);
try{
//do some queries using both entityManager and hibernateSession
}finally{
this.entityManager.close();
}
But I seem to have a connection leak somewhere. I'm wondering if I am supposed to close both entityManager and hibernateSession. Has anybody else worked with this type of situation?