From bc76fcb7fc649cf1fc89a51cf3ddba7ade6b7e3c Mon Sep 17 00:00:00 2001 From: Jens Schauder Date: Wed, 28 Oct 2020 14:45:38 +0100 Subject: [PATCH] DATACMNS-800 - Adds deleteAllById to ReactiveCrudRepository and CrudRepository. CrudRepository and ReactiveCrudRepository now expose a deleteAllById(Iterable) method to delete multiple entities by their Id. Original pull request: #476. --- .../data/repository/CrudRepository.java | 10 ++++++++++ .../repository/reactive/ReactiveCrudRepository.java | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/main/java/org/springframework/data/repository/CrudRepository.java b/src/main/java/org/springframework/data/repository/CrudRepository.java index feeb07f7b..28a30a2d4 100644 --- a/src/main/java/org/springframework/data/repository/CrudRepository.java +++ b/src/main/java/org/springframework/data/repository/CrudRepository.java @@ -22,6 +22,7 @@ import java.util.Optional; * * @author Oliver Gierke * @author Eberhard Wolff + * @author Jens Schauder */ @NoRepositoryBean public interface CrudRepository extends Repository { @@ -117,6 +118,15 @@ public interface CrudRepository extends Repository { */ void deleteAll(Iterable entities); + /** + * Deletes all instances of the type {@code T} with the given IDs. + * + * @param ids must not be {@literal null}. Must not contain {@literal null} elements. + * @throws IllegalArgumentException in case the given {@literal ids} or one of its elements is {@literal null}. + * @since 2.5 + */ + void deleteAllById(Iterable ids); + /** * Deletes all entities managed by the repository. */ diff --git a/src/main/java/org/springframework/data/repository/reactive/ReactiveCrudRepository.java b/src/main/java/org/springframework/data/repository/reactive/ReactiveCrudRepository.java index 022084b99..77d929418 100644 --- a/src/main/java/org/springframework/data/repository/reactive/ReactiveCrudRepository.java +++ b/src/main/java/org/springframework/data/repository/reactive/ReactiveCrudRepository.java @@ -28,6 +28,7 @@ import org.springframework.data.repository.Repository; * * @author Mark Paluch * @author Christph Strobl + * @author Jens Schauder * @since 2.0 * @see Mono * @see Flux @@ -179,6 +180,17 @@ public interface ReactiveCrudRepository extends Repository { */ Mono deleteAll(Iterable entities); + /** + * Deletes all instances of the type {@code T} with the given IDs. + * + * @param ids must not be {@literal null}. + * @return {@link Mono} signaling when operation has completed. + * @throws IllegalArgumentException in case the given {@literal ids} or one of its elements is {@literal null}. + * {@literal null}. + * @since 2.5 + */ + Mono deleteAllById(Iterable ids); + /** * Deletes the given entities supplied by a {@link Publisher}. *