This can happen when merging an entity has a "post-insert" ID that requires an insert to obtain the ID (e.g., identity ID).
Currently, when a transient entity with a post-insert ID is merged: 1) a new entity is instantiated; 2) basic properties and associations with {{AssociationType.getForeignKeyDirection() == ForeignKeyDirection#FROM_PARENT}} are copied to the new entity; 3) all inserts in the ActionQueue are executed; 4) PrePersist callback is called prior to inserting the new entity; the new entity is inserted 4) associations with {{AssociationType.getForeignKeyDirection() == ForeignKeyDirection#TO_PARENT}} are copied to the new entity.
If the
Because Validator is a PrePersist Merge operation throws a ConstraintValidationException on non-empty list marked as when using @OneToMany & @NotNull "null" is always passed to the validator during a merge operation, even when the collection is non-empty, causing this operation to fail with C.V.E.
For more details see: https://bugzilla.redhat.com/show_bug.cgi?id=1245082
|