From fef40437e4b3c3e62ce49a6f33e571ac6b3b86f8 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Fri, 31 Jan 2025 10:58:58 +0100 Subject: [PATCH] Refine performance requirements on derived delete queries. Closes #3177 --- src/main/antora/modules/ROOT/pages/jpa/query-methods.adoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/antora/modules/ROOT/pages/jpa/query-methods.adoc b/src/main/antora/modules/ROOT/pages/jpa/query-methods.adoc index 81eee4ecb..cfa303957 100644 --- a/src/main/antora/modules/ROOT/pages/jpa/query-methods.adoc +++ b/src/main/antora/modules/ROOT/pages/jpa/query-methods.adoc @@ -601,6 +601,9 @@ To make sure lifecycle queries are actually invoked, an invocation of `deleteByR In fact, a derived delete query is a shortcut for running the query and then calling `CrudRepository.delete(Iterable users)` on the result and keeping behavior in sync with the implementations of other `delete(…)` methods in `CrudRepository`. +NOTE: When deleting a lot of objects you will need to consider the performance implications to ensure sufficient memory availability. +All resulting objects are loaded into memory before being deleted and are held in the session until flushing or completing the transaction. + [[jpa.query-hints]] == Applying Query Hints To apply JPA query hints to the queries declared in your repository interface, you can use the `@QueryHints` annotation. It takes an array of JPA `@QueryHint` annotations plus a boolean flag to potentially disable the hints applied to the additional count query triggered when applying pagination, as shown in the following example: