EntityManager.isOpen() should respect status of Session

Description

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:

org.hibernate.jpa.internal.EntityManagerImpl.isOpen()

Should this method look like this?

Fixed version of org.hibernate.jpa.internal.EntityManagerImpl.isOpen()

Environment

None

Activity

Show:
Thomas Scheffler
March 22, 2016, 7:30 AM

A simple test case:

Andrea Boriero
March 30, 2016, 10:54 AM
Andrea Boriero
May 12, 2016, 8:02 AM

applied to 5.1

Gail Badner
May 25, 2016, 10:52 PM

, backported to 5.0 branch. Thanks!

Assignee

Andrea Boriero

Reporter

Thomas Scheffler

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Minor
Configure