Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ghusta opened this issue Jan 24, 2022 · 1 comment
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement
Milestone

Comments

@ghusta
Copy link

ghusta commented Jan 24, 2022

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
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 24, 2022
@jhoeller jhoeller added in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 24, 2022
@jhoeller jhoeller added this to the 5.3.16 milestone Jan 24, 2022
@jhoeller jhoeller self-assigned this Jan 24, 2022
@ghusta
Copy link
Author

ghusta commented Jan 26, 2022

Thanks @jhoeller 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants