Skip to content

Inconsistent behaviour in spring-orm between EntityManagerFactoryUtils.closeEntityManager() and SessionFactoryUtils.closeSession() #27972

Closed
@ghusta

Description

@ghusta

Whereas EntityManagerFactoryUtils.closeEntityManager() will check if EntityManager is open before trying to close it, SessionFactoryUtils.closeSession() doesn't check if session is open.

As a consequence, if EntityManager is closed when entering closeEntityManager(), nothing will happen,
whereas if Session is closed when entering closeSession(), a log ERROR will be generated (because of "org.hibernate.SessionException: Session was already closed") (tested with Spring 5.2 + Hibernate 5.1).

Maybe we could have a common behaviour between both classes ?

See related commit for EntityManagerFactoryUtils : 928f542


Context :

  • module spring-orm
    • class org.springframework.orm.jpa.EntityManagerFactoryUtils
    • class org.springframework.orm.hibernate5.SessionFactoryUtils

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions