DATAJDBC-629 - Implements CrudRepository.deleteAllById(Iterable<ID>).

Original pull request: #252.
This commit is contained in:
Jens Schauder
2020-11-03 16:30:55 +01:00
committed by Mark Paluch
parent 636a81a46d
commit c0d337d715
3 changed files with 25 additions and 0 deletions

View File

@@ -155,6 +155,11 @@ public class SimpleJdbcRepository<T, ID> implements PagingAndSortingRepository<T
entityOperations.deleteAll(entity.getType());
}
@Override
public void deleteAllById(Iterable<? extends ID> ids) {
ids.forEach(it -> entityOperations.deleteById(it, entity.getType()));
}
/*
* (non-Javadoc)
* @see org.springframework.data.repository.PagingAndSortingRepository#findAll(org.springframework.data.domain.Sort sort)
@@ -172,4 +177,5 @@ public class SimpleJdbcRepository<T, ID> implements PagingAndSortingRepository<T
public Page<T> findAll(Pageable pageable) {
return entityOperations.findAll(entity.getType(), pageable);
}
}

View File

@@ -204,6 +204,20 @@ public class JdbcRepositoryIntegrationTests {
.containsExactlyInAnyOrder(two.getIdProp());
}
@Test // DATAJDBC-629
public void deleteByIdList() {
DummyEntity one = repository.save(createDummyEntity());
DummyEntity two = repository.save(createDummyEntity());
DummyEntity three = repository.save(createDummyEntity());
repository.deleteAllById(asList(one.idProp, three.idProp));
assertThat(repository.findAll()) //
.extracting(DummyEntity::getIdProp) //
.containsExactlyInAnyOrder(two.getIdProp());
}
@Test // DATAJDBC-97
public void deleteAll() {

View File

@@ -228,5 +228,10 @@ public class EnableJdbcRepositoriesIntegrationTests {
public void deleteAll() {
}
@Override
public void deleteAllById(Iterable<? extends ID> ids) {
}
}
}