DATAJPA-1818 - Rename JpaRepository.deleteInBatch to match names in CrudRepository.
Original pull request: #435.
This commit is contained in:
committed by
Mark Paluch
parent
38457e6d40
commit
296cef790f
@@ -77,12 +77,28 @@ public interface JpaRepository<T, ID> extends PagingAndSortingRepository<T, ID>,
|
||||
<S extends T> S saveAndFlush(S entity);
|
||||
|
||||
/**
|
||||
* Deletes the given entities in a batch which means it will create a single {@link Query}. Assume that we will clear
|
||||
* the {@link javax.persistence.EntityManager} after the call.
|
||||
* Deletes the given entities in a batch which means it will create a single {@link Query}.
|
||||
*
|
||||
* This kind of operation leaves JPAs first level cache and the database out of sync.
|
||||
* Consider flushing the `EntityManager` before calling this method.
|
||||
*
|
||||
* @param entities
|
||||
* @deprecated Use {@link #deleteAllInBatch(Iterable)} instead.
|
||||
*/
|
||||
void deleteInBatch(Iterable<T> entities);
|
||||
@Deprecated
|
||||
default void deleteInBatch(Iterable<T> entities){deleteAllInBatch(entities);}
|
||||
|
||||
/**
|
||||
* Deletes the given entities in a batch which means it will create a single {@link Query}.
|
||||
*
|
||||
* This kind of operation leaves JPAs first level cache and the database out of sync.
|
||||
* Consider flushing the `EntityManager` before calling this method.
|
||||
*
|
||||
* @param entities
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
void deleteAllInBatch(Iterable<T> entities);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -234,7 +234,7 @@ public class SimpleJpaRepository<T, ID> implements JpaRepositoryImplementation<T
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public void deleteInBatch(Iterable<T> entities) {
|
||||
public void deleteAllInBatch(Iterable<T> entities) {
|
||||
|
||||
Assert.notNull(entities, "Entities must not be null!");
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ import static org.springframework.data.jpa.domain.Specification.not;
|
||||
import static org.springframework.data.jpa.domain.sample.UserSpecifications.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@@ -259,7 +258,7 @@ public class UserRepositoryTests {
|
||||
|
||||
long before = repository.count();
|
||||
|
||||
repository.deleteInBatch(asList(firstUser, secondUser));
|
||||
repository.deleteAllInBatch(asList(firstUser, secondUser));
|
||||
|
||||
assertThat(repository.existsById(firstUser.getId())).isFalse();
|
||||
assertThat(repository.existsById(secondUser.getId())).isFalse();
|
||||
|
||||
Reference in New Issue
Block a user