Pass entity in repository delete(entity) and deleteAll(entities). (#1726)

Closes #1725.
This commit is contained in:
Michael Reiche
2023-05-03 15:28:50 -07:00
committed by GitHub
parent 7edc00e10c
commit ffe7c52f28
2 changed files with 3 additions and 3 deletions

View File

@@ -111,7 +111,7 @@ public class SimpleCouchbaseRepository<T, ID> extends CouchbaseRepositoryBase<T,
@Override
public void delete(T entity) {
Assert.notNull(entity, "Entity must not be null!");
operations.removeById(getJavaType()).inScope(getScope()).inCollection(getCollection()).one(getId(entity));
operations.removeById(getJavaType()).inScope(getScope()).inCollection(getCollection()).oneEntity(entity);
}
@Override
@@ -125,7 +125,7 @@ public class SimpleCouchbaseRepository<T, ID> extends CouchbaseRepositoryBase<T,
public void deleteAll(Iterable<? extends T> entities) {
Assert.notNull(entities, "The given Iterable of entities must not be null!");
operations.removeById(getJavaType()).inScope(getScope()).inCollection(getCollection())
.all(Streamable.of(entities).map(this::getId).toList());
.allEntities((Collection<Object>)Streamable.of(entities).toList());
}
@Override

View File

@@ -113,7 +113,7 @@ public class CouchbaseRepositoryKeyValueIntegrationTests extends ClusterAwareInt
assertThrows(DuplicateKeyException.class, () -> userRepository.save(user));
user.setVersion(saveVersion + 1);
assertThrows(OptimisticLockingFailureException.class, () -> userRepository.save(user));
userRepository.delete(user);
userRepository.deleteById(user.getId());
// Airline does not have a version
Airline airline = new Airline(UUID.randomUUID().toString(), "MyAirline", null);