#2728 - Fix for stateless update with orphanRemoval=true and softDelete

This commit is contained in:
Rob Bygrave committed 2022-07-04 12:22:27 +12:00
1 parent 5b92ac6e02
commit d20d276d56
2 files changed
+28 -20

No files matched your search

@@ -126,7 +126,7 @@ final class SaveManyBeans extends SaveManyBase {
// performance optimisation for large collections
targetDescriptor.preAllocateIds(collection.size());
}
if (!insertedParent && many.isOrphanRemoval() && request.isForcedUpdate()) {
if (forcedUpdateOrphanRemoval()) {
// collect the Id's (to exclude from deleteManyDetails)
List<Object> detailIds = collectIds(collection, targetDescriptor, isMap);
// deleting missing children - children not in our collected detailIds
@@ -140,6 +140,10 @@ final class SaveManyBeans extends SaveManyBase {
transaction.depth(-1);
}
private boolean forcedUpdateOrphanRemoval() {
return !insertedParent && many.isOrphanRemoval() && request.isForcedUpdate();
}
private void saveAllBeans(final BeanProperty orderColumn) {
Object mapKeyValue = null;
boolean skipSavingThisBean;
@@ -340,7 +344,7 @@ final class SaveManyBeans extends SaveManyBase {
return;
}
if (!(value instanceof BeanCollection<?>)) {
if (!insertedParent && cascade && isChangedProperty()) {
if (!forcedUpdateOrphanRemoval() && (!insertedParent && cascade && isChangedProperty())) {
persister.addToFlushQueue(many.deleteByParentId(request.beanId(), null), transaction, 0);
insertAllChildren = true;
}