DATAJPA-363 - Improved implementation of SimpleJpaRepository.delete(ID id).
Remove the additional call to exists(…) in favor of a null check, we'd have to trigger anyway in the case of and exists success. This will avoid triggering an additional query.
This commit is contained in:
@@ -125,12 +125,14 @@ public class SimpleJpaRepository<T, ID extends Serializable> implements JpaRepos
|
||||
|
||||
Assert.notNull(id, "The given id must not be null!");
|
||||
|
||||
if (!exists(id)) {
|
||||
T entity = findOne(id);
|
||||
|
||||
if (entity == null) {
|
||||
throw new EmptyResultDataAccessException(String.format("No %s entity with id %s exists!",
|
||||
entityInformation.getJavaType(), id), 1);
|
||||
}
|
||||
|
||||
delete(findOne(id));
|
||||
delete(entity);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user