Merge of detached, enhanced entity with orphanRemoval = true collection fails since 5.2.13

Description

This is slightly related to the but here we're trying to merge a detached entity.
This worked in 5.2.12. Does not in 5.2.13+ including latest 5.3.0.

The result is

1 2 3 4 5 6 7 8 9 10 Caused by: org.hibernate.HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: org.hibernate.bugs.model.Container.elements at org.hibernate.engine.internal.Collections.processDereferencedCollection(Collections.java:99) at org.hibernate.engine.internal.Collections.processUnreachableCollection(Collections.java:50) at org.hibernate.event.internal.AbstractFlushingEventListener.flushCollections(AbstractFlushingEventListener.java:243) at org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:86) at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:38) at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1437) at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:493) at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3207) at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2413)

Environment

None

Status

Assignee

Chris Cranford

Reporter

Jacek Krüger

Fix versions

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

5.2.12

Affects versions

5.2.13
5.3.0.Final

Priority

Major