Session closed exception when using Envers in a JTA transaction

Description

After upgrade from Hibernate 5.1.0 releate to 5.2.4 there is error with JTA Transactions with Spring and Envers audited JPA entities.

Session is closed before AuditProces insert revision data. Spring JtaTransactionManager closed it in commit() and nested synchronization releaseResource() method.
Before Hibernate 5.2.0 session was not closed when in active transaction.

In attachment is unit test (JtaTransactionWithSpringReleaseResource.java) for Envers where entityManager.close() method is invoked in transaction. In 5.1.x codebase is running without errors.
Complete runable maven project with configured Spring, Hibernate, JTA and unit test is in another attachment.

Thank you for quick response.

Environment

Spring, JTA

Status

Assignee

Andrea Boriero

Reporter

LAdO

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

5.2.2
5.2.4
5.2.3
5.2.0
5.2.1

Priority

Critical
Configure