Session from SessionFactory.getCurrentSession not synchronized with current JPA transaction on Hibernate 5.2 [SPR-16915] #21454
Labels
in: data
Issues in data modules (jdbc, orm, oxm, tx)
status: declined
A suggestion or change that we don't feel we should currently apply
type: enhancement
A general enhancement
Marten Deinum opened SPR-16915 and commented
When using Hibernate 5.2 and using an unwrapped (or cast)
SessionFactory
to get the current session usinggetCurrentSession
this doesn't get synchronized with the current transaction.This is mainly due to the change in Hibernate 5.2 that
Session
now extendsEntityManager
which will create an unsynchronizedEntityManager
leading to an exception when the transaction will commit.This all happens in the
invokeProxyMethod
in theAbstractEntityManagerFactoryBean
. I guess that method should also treat thegetCurrentSession
method like it does thecreateEntityManager
method withSynchronizationType.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 extendEntityManager
.Affects: 4.3.17, 5.0.6
Issue Links:
The text was updated successfully, but these errors were encountered: