Skip to content

Session from SessionFactory.getCurrentSession not synchronized with current JPA transaction on Hibernate 5.2 [SPR-16915] #21454

Closed
@spring-projects-issues

Description

@spring-projects-issues

Marten Deinum opened SPR-16915 and commented

When using Hibernate 5.2 and using an unwrapped (or cast) SessionFactory to get the current session using getCurrentSession this doesn't get synchronized with the current transaction. 

This is mainly due to the change in Hibernate 5.2 that Session now extends EntityManager which will create an unsynchronized EntityManager leading to an exception when the transaction will commit. 

This all happens in the invokeProxyMethod in the AbstractEntityManagerFactoryBean. I guess that method should also treat the getCurrentSession method like it does the createEntityManager method with SynchronizationType.SYNCHRONIZED is used. 

NOTE: This only happens with Hibernate 5.2 (or up) with lower versions there (probably) isn't an issue as there Session doesn't extend EntityManager.


Affects: 4.3.17, 5.0.6

Issue Links:

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions