'A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance' when persisting, flushing, detaching and merging an Entity in the same Session (using Bytecode enhancement)

Description

I came across this strange bug while implementing lazy loading using Bytecode enhancement in our application. At some point in our code, we do the following operations in a single session:

(obviously very simplified)

With relevant Entities:
>>Item.java

>>SubItem.java

>>Association.java

The Code works fine with bytecode enhancement in Version 5.2.12. In higher Versions of Hibernate the code fails on the second flush with an Exception:

org.hibernate.HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: hibernate.model.SubItem.superAssociation

If we turn off bytecode enhancement, it works fine in all the versions I have tried.
See the attached Test Case for the concrete example.

Environment

java version: 1.8.0_92
maven version: 3.6.1
OS: Windows 10
DB: Derby (10.12.1.1), Oracle DB 19c

Activity

Show:
Alexander Bittermann
February 26, 2020, 3:45 PM

Still experiencing the same problem in version 5.4.12. What’s the status on this?

Thom Schanzleh
September 23, 2020, 9:44 AM

We’re also experiencing this issue. Is there any progress to report? We’re on version 5.4.6.

Assignee

Unassigned

Reporter

Andreas Burkhart

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

5.2.12

Components

Affects versions

Priority

Major
Configure