Issue
I am trying to batch delete n objects with JPA repository deleteAll(List entities), and it works. But at the end it produces n queries to the database instead of grouping elements by the batch size.
Expected behaviour:
- 20 entities to delete
- batch size 10
- queries to the database 2
Actual behaviour:
- 20 entities to delete
- batch size 10
- queries to the database 20
If I do the batch update saveAll(List entities) I am getting expected behaviour with 2 queries produced.
Solution
deleteAll(List entities) will delete all objects in one session, so the number of queries will be the n, grouped by the batch_size.
Answered By - Gligorije Nikolic