Skip to content

Commit 833445b

Browse files
committed
DATAJPA-1818 - Rename JpaRepository.deleteInBatch to match names in CrudRepository
1 parent e466cdb commit 833445b

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

src/main/java/org/springframework/data/jpa/repository/JpaRepository.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,28 @@ public interface JpaRepository<T, ID> extends PagingAndSortingRepository<T, ID>,
7777
<S extends T> S saveAndFlush(S entity);
7878

7979
/**
80-
* Deletes the given entities in a batch which means it will create a single {@link Query}. Assume that we will clear
81-
* the {@link javax.persistence.EntityManager} after the call.
80+
* Deletes the given entities in a batch which means it will create a single {@link Query}.
81+
*
82+
* This kind of operation leaves JPAs first level cache and the database out of sync.
83+
* Consider flushing the `EntityManager` before calling this method.
8284
*
8385
* @param entities
86+
* @deprecated Use {@link #deleteAllInBatch(Iterable)} instead.
87+
*/
88+
@Deprecated
89+
default void deleteInBatch(Iterable<T> entities){deleteAllInBatch(entities);}
90+
91+
/**
92+
* Deletes the given entities in a batch which means it will create a single {@link Query}.
93+
*
94+
* This kind of operation leaves JPAs first level cache and the database out of sync.
95+
* Consider flushing the `EntityManager` before calling this method.
96+
*
97+
* @param entities
98+
*
99+
* @since 3.0
84100
*/
85-
void deleteInBatch(Iterable<T> entities);
101+
void deleteAllInBatch(Iterable<T> entities);
86102

87103

88104
/**

src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public void deleteAllById(Iterable<? extends ID> ids) {
234234
*/
235235
@Transactional
236236
@Override
237-
public void deleteInBatch(Iterable<T> entities) {
237+
public void deleteAllInBatch(Iterable<T> entities) {
238238

239239
Assert.notNull(entities, "Entities must not be null!");
240240

src/test/java/org/springframework/data/jpa/repository/UserRepositoryTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import static org.springframework.data.jpa.domain.sample.UserSpecifications.*;
2626

2727
import java.util.ArrayList;
28-
import java.util.Arrays;
2928
import java.util.Collection;
3029
import java.util.Collections;
3130
import java.util.HashSet;
@@ -259,7 +258,7 @@ void batchDeleteCollectionOfEntities() {
259258

260259
long before = repository.count();
261260

262-
repository.deleteInBatch(asList(firstUser, secondUser));
261+
repository.deleteAllInBatch(asList(firstUser, secondUser));
263262

264263
assertThat(repository.existsById(firstUser.getId())).isFalse();
265264
assertThat(repository.existsById(secondUser.getId())).isFalse();

0 commit comments

Comments
 (0)