I currently do not have time for the test, also because this blocks me: #6738. I try to add one asap.
Issue is the following:
Preconditions:
- You have an OneToMany with orphanRemoval set from the one-side.
- On the many-side you have a unique constraint
You do the following in a single transaction/flush:
- Remove some entities from the many-side
- Create new entities on the many-side
When the column value (unique constraint) on the removed entities (1) equals the column value (unique constraint) on the created entities (2) a constraint violation is raised.
Reason:
The created entities (2) are INSERTed before the removed entities (1) are DELETEd.
Found a fixed, similar issue, just ManyToMany: #2310