Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

JdbcAggregateOperations delete by query #2084

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

Open
ghgh415263 wants to merge 1 commit into spring-projects:main
base: main
Choose a base branch
Loading
from ghgh415263:GH-1978

Conversation

Copy link
Contributor

@ghgh415263 ghgh415263 commented Jul 12, 2025

Issue link: #1978

Add deleteAllByQuery method to JdbcAggregateOperations

This method enables deleting aggregates based on a query by performing the following steps:

  1. Select root IDs matching the query with a SELECT ... FOR UPDATE to lock the rows.
  2. Delete all sub-entities associated with the selected root IDs.
  3. Delete the root entities identified by the selected IDs.

see
#1978

Copy link
Contributor Author

I’ve opened a draft PR for #1978. If you have any suggestions for improvement or spot any issues, I’d be glad to make the necessary changes. Thank you for reviewing it!

@mp911de mp911de added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 14, 2025
Copy link
Contributor

@schauder schauder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of this looks pretty good.
I have on major concern though: We should not transfer the ids from the locking select to the client and use it for follow up deletes.

Instead the locking select should execute on the server only, and the delete operations should be based on the query directly.

The reason for this that this operation is very attractive for large amounts of data. In such cases transporting and converting the ids creates serious load on network and memory.

And if someone prefers to select the ids first and then delete based on these ids they can still do that using multiple methods.

ghgh415263 reacted with thumbs up emoji
Copy link
Contributor Author

Thanks for review

i Changed the steps as follows:

  1. Lock the target rows using SELECT ... FOR UPDATE based on the query conditions.
  2. Delete sub-entities by leveraging a subquery that selects the matching root rows.
  3. Delete the root entities using the query conditions.

Copy link
Contributor Author

Hello

It looks like other commits were merged and now my previous PR has a conflict. Should I resolve it and push again?. and I can also make any improvements to my PR.

Copy link
Contributor

Hello

It looks like other commits were merged and now my previous PR has a conflict. Should I resolve it and push again?. and I can also make any improvements to my PR.

That would be awesome

Issue link: spring-projects#1978
Add deleteAllByQuery method to JdbcAggregateOperations
This method enables deleting aggregates based on a query by performing the following steps:
1. Lock the target rows using SELECT ... FOR UPDATE based on the query conditions.
2. Delete sub-entities by leveraging a subquery that selects the matching root rows.
3. Delete the root entities using the query conditions.
But if the query has no criteria, deletion is performed in the same way as deleteAll method of JdbcAggregateOperations
Signed-off-by: JaeYeon Kim <ghgh415263@naver.com>
Copy link
Contributor Author

hello !
I’ve resolved the conflicts and made some minor adjustments before pushing again.

@schauder schauder linked an issue Aug 28, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@schauder schauder Awaiting requested review from schauder

Labels
type: enhancement A general enhancement
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

JdbcAggregateOperations delete by query

AltStyle によって変換されたページ (->オリジナル) /