Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2961 - Followup for #2952 - @OneToMany + orphanRemoval + @SoftDelete + non-BeanCollection collection results in hard deletes #2962

Merged
merged 1 commit into from
Feb 10, 2023

Conversation

rbygrave
Copy link
Member

As noted in comments in #2952

In the internals of SaveManyBeans we have:

  • BUG: the deleteByParentId is hard delete and does not care for soft delete
  • YUK: internally we have 3 ways of performing the orphan removal when we really want 2

This change fixes the BUG and fixes the YUK. It does this by removing the special case at: https://github.com/ebean-orm/ebean/blob/ebean-parent-13.11.3/ebean-core/src/main/java/io/ebeaninternal/server/persist/SaveManyBeans.java#L347-L350 ... and replacing it with the more common orphan removal code used when we do not have BeanCollection modifications.

The result of this change is that in SaveManyBeans internals we get back to have 2 ways to remove orphans.

  • A BeanCollection with modifications: Orphans explicitly deleted using the known elements removed from the collection
  • All other cases: Orphans as everything NOT in the collection that is going to be updated

… + non-BeanCollection collection results in hard deletes

As noted in comments in #2952

In the internals of SaveManyBeans we have:

- BUG: the deleteByParentId is hard delete and does not care for soft delete
- YUK: internally we have 3 ways of performing the orphan removal when we really want 2

This change fixes the BUG and fixes the YUK. It does this by removing the special case at: https://github.com/ebean-orm/ebean/blob/ebean-parent-13.11.3/ebean-core/src/main/java/io/ebeaninternal/server/persist/SaveManyBeans.java#L347-L350 ... and replacing it with the more common orphan removal code used when we do not have BeanCollection modifications.

The result of this change is that in SaveManyBeans internals we get back to have 2 ways to remove orphans.

- A BeanCollection with modifications: Orphans explicitly deleted using the known elements removed from the collection
- All other cases: Orphans as everything NOT in the collection that is going to be updated
@rbygrave rbygrave added this to the 13.11.4 milestone Feb 10, 2023
@rbygrave rbygrave self-assigned this Feb 10, 2023
@rbygrave rbygrave merged commit 1176c2e into master Feb 10, 2023
@rbygrave rbygrave deleted the feature/2961 branch February 10, 2023 00:10
@rbygrave
Copy link
Member Author

Also refer to previous issue #2127 (which introduces that special case handling that we have now merged into the more normal handling of orphan removal for non-BeanCollection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant