I use the unwrap() method as a bridge to make old hibernate code runnable on top of JPA classes while migrating. I keep track of EntityManager creation and closing like the SessionContext used in Hibernate.
But if legacy code closes the Session the EntityManager.isOpen() still returns true and after calling close() I get an Exception that the Session was already closed.
I noticed this may be the source of the error:
Should this method look like this?
Fixed version of org.hibernate.jpa.internal.EntityManagerImpl.isOpen()
A simple test case:
applied to 5.1
, backported to 5.0 branch. Thanks!