After using the unwrap method on entitymanager to get the native hibernate session do I have to close both?
问题 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? 回答1: You do not