Persist cascade of collection fails when orphan removal enabled with flush mode commit.

Description

I trying to update version of hibernate from 5.2.12 to 5.3.2
When persisting parent-child, one-to-many relationship with cascade-all and orphan-removal true, the following HibernateException is thrown:

1 Caused by: org.hibernate.HibernateException: Don't change the reference to a collection with delete-orphan enabled : su.axada.hibernate.sandbox.model.DocumentA.lines

Exception is throwing only if flushMode = COMMIT, if I'll set it to AUTO exception will gone.

One more important thing is: I use envers if I'll remove @Audited annotation then no matter what value has flushMode and exception will gone.

I think that the successful persisting of an object should not depend on the value of flushMode when using envers.

In attachment you can find test ceses in class JPAUnitTestCase

Environment

<spring.boot.version>2.0.0.RELEASE</spring.boot.version>
<h2db.version>1.4.191</h2db.version>
<hibernate.version>5.3.2.Final</hibernate.version>

Status

Assignee

Chris Cranford

Reporter

Anton Mityagin

Fix versions

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

5.2.12

Components

Affects versions

5.3.1
5.3.2
5.3.0.Final

Priority

Major