Skip to content

Commit

Permalink
HHH-15159 Orphan removal of an entity with an @ElementCollection caus…
Browse files Browse the repository at this point in the history
…es a ConstraintViolationException
  • Loading branch information
dreab8 authored and beikov committed Sep 2, 2022
1 parent 6c3d700 commit 41b067e
Showing 1 changed file with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,23 @@ public class ActionQueue {
private static final LinkedHashMap<Class<? extends Executable>,ListProvider<?>> EXECUTABLE_LISTS_MAP;
static {
EXECUTABLE_LISTS_MAP = CollectionHelper.linkedMapOfSize( 8 );

/*
CollectionRemoveAction actions have to be executed before OrphanRemovalAction actions, to prevent a constraint violation
when deleting an orphan Entity that contains an ElementCollection (see HHH-15159)
*/
EXECUTABLE_LISTS_MAP.put(
CollectionRemoveAction.class,
new ListProvider<CollectionRemoveAction>() {
ExecutableList<CollectionRemoveAction> get(ActionQueue instance) {
return instance.collectionRemovals;
}
ExecutableList<CollectionRemoveAction> init(ActionQueue instance) {
return instance.collectionRemovals = new ExecutableList<>(
instance.isOrderUpdatesEnabled()
);
}
}
);
EXECUTABLE_LISTS_MAP.put(
OrphanRemovalAction.class,
new ListProvider<OrphanRemovalAction>() {
Expand Down Expand Up @@ -166,19 +182,6 @@ ExecutableList<QueuedOperationCollectionAction> init(ActionQueue instance) {
}
}
);
EXECUTABLE_LISTS_MAP.put(
CollectionRemoveAction.class,
new ListProvider<CollectionRemoveAction>() {
ExecutableList<CollectionRemoveAction> get(ActionQueue instance) {
return instance.collectionRemovals;
}
ExecutableList<CollectionRemoveAction> init(ActionQueue instance) {
return instance.collectionRemovals = new ExecutableList<>(
instance.isOrderUpdatesEnabled()
);
}
}
);
EXECUTABLE_LISTS_MAP.put(
CollectionUpdateAction.class,
new ListProvider<CollectionUpdateAction>() {
Expand Down

0 comments on commit 41b067e

Please sign in to comment.