Added deleteInBatch method to JpaRepository.

Reverted implementation of delete(Iterable<T> entities) to iterate over the entities as creating a query can cause the persistence provider to choke on really large entity sets. Beyond that triggering a query would require us to clear the persistence context which might not be wanted in every case. Thus an additional method deleteInBatch(Iterable<T> entities) especially available on the JpaRepository interface now triggers the query but clearly states the assumptions and side effects in the JavaDoc. Removed some obsolete finals and an obsolete method.
This commit is contained in:
Oliver Gierke
2011-02-03 19:57:22 +00:00
parent 733d9518c8
commit 6b1aabfa91
3 changed files with 72 additions and 39 deletions

View File

@@ -225,6 +225,18 @@ public class UserRepositoryTests {
}
@Test
public void batchDeleteColletionOfEntities() {
flushTestUsers();
long before = repository.count();
repository.deleteInBatch(Arrays.asList(firstUser, secondUser));
assertThat(repository.count(), is(before - 2));
}
@Test
public void deleteEmptyCollectionDoesNotDeleteAnything() {