#6776·orm

oneToMany orphanRemoval with unique - constraint violation

Author: akommCreated Oct 16, 2017Updated Aug 25, 2026
LabelsFailing TestBug

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:

  1. Remove some entities from the many-side
  2. 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