spring-data-relational icon indicating copy to clipboard operation
spring-data-relational copied to clipboard

JdbcAggregateOperations delete by query

Open ghgh415263 opened this issue 6 months ago • 6 comments

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

ghgh415263 avatar Jul 12 '25 11:07 ghgh415263

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!

ghgh415263 avatar Jul 12 '25 11:07 ghgh415263

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.

ghgh415263 avatar Jul 17 '25 07:07 ghgh415263

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.

ghgh415263 avatar Aug 11 '25 05:08 ghgh415263

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

schauder avatar Aug 11 '25 06:08 schauder

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

ghgh415263 avatar Aug 15 '25 11:08 ghgh415263

I’ve resolved new conflicts.

ghgh415263 avatar Sep 09 '25 13:09 ghgh415263