DATAKV-176 - Adapt to API changes in repository interfaces.
We now follow a more consistent naming scheme for the methods in repository that are driven by the following guidelines: * Methods referring to an identifier now all end on …ById(…). * Methods taking or returning a collection are named …All(…) Please see DATACMNS-944 for details.
This commit is contained in:
committed by
Oliver Gierke
parent
3f21f10d78
commit
aa6e412602
@@ -111,7 +111,7 @@ public class KeyValueRepositoryFactory extends RepositoryFactorySupport {
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T, ID extends Serializable> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {
|
||||
public <T, ID> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {
|
||||
|
||||
PersistentEntity<T, ?> entity = (PersistentEntity<T, ?>) context.getPersistentEntity(domainClass).get();
|
||||
PersistentEntityInformation<T, ID> entityInformation = new PersistentEntityInformation<>(entity);
|
||||
|
||||
@@ -107,7 +107,7 @@ public class SimpleKeyValueRepository<T, ID extends Serializable> implements Key
|
||||
* @see org.springframework.data.repository.CrudRepository#save(java.lang.Iterable)
|
||||
*/
|
||||
@Override
|
||||
public <S extends T> Iterable<S> save(Iterable<S> entities) {
|
||||
public <S extends T> Iterable<S> saveAll(Iterable<S> entities) {
|
||||
|
||||
for (S entity : entities) {
|
||||
save(entity);
|
||||
@@ -121,7 +121,7 @@ public class SimpleKeyValueRepository<T, ID extends Serializable> implements Key
|
||||
* @see org.springframework.data.repository.CrudRepository#findOne(java.io.Serializable)
|
||||
*/
|
||||
@Override
|
||||
public Optional<T> findOne(ID id) {
|
||||
public Optional<T> findById(ID id) {
|
||||
return operations.findById(id, entityInformation.getJavaType());
|
||||
}
|
||||
|
||||
@@ -130,8 +130,8 @@ public class SimpleKeyValueRepository<T, ID extends Serializable> implements Key
|
||||
* @see org.springframework.data.repository.CrudRepository#exists(java.io.Serializable)
|
||||
*/
|
||||
@Override
|
||||
public boolean exists(ID id) {
|
||||
return findOne(id) != null;
|
||||
public boolean existsById(ID id) {
|
||||
return findById(id) != null;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -148,13 +148,13 @@ public class SimpleKeyValueRepository<T, ID extends Serializable> implements Key
|
||||
* @see org.springframework.data.repository.CrudRepository#findAll(java.lang.Iterable)
|
||||
*/
|
||||
@Override
|
||||
public Iterable<T> findAll(Iterable<ID> ids) {
|
||||
public Iterable<T> findAllById(Iterable<ID> ids) {
|
||||
|
||||
List<T> result = new ArrayList<>();
|
||||
|
||||
for (ID id : ids) {
|
||||
|
||||
Optional<T> candidate = findOne(id);
|
||||
Optional<T> candidate = findById(id);
|
||||
|
||||
if (candidate.isPresent()) {
|
||||
result.add(candidate.get());
|
||||
@@ -178,7 +178,7 @@ public class SimpleKeyValueRepository<T, ID extends Serializable> implements Key
|
||||
* @see org.springframework.data.repository.CrudRepository#delete(java.io.Serializable)
|
||||
*/
|
||||
@Override
|
||||
public void delete(ID id) {
|
||||
public void deleteById(ID id) {
|
||||
operations.delete(id, entityInformation.getJavaType());
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ public class SimpleKeyValueRepository<T, ID extends Serializable> implements Key
|
||||
*/
|
||||
@Override
|
||||
public void delete(T entity) {
|
||||
delete(entityInformation.getId(entity)
|
||||
deleteById(entityInformation.getId(entity)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Cannot delete entity with 'null' id.")));
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ public class SimpleKeyValueRepository<T, ID extends Serializable> implements Key
|
||||
* @see org.springframework.data.repository.CrudRepository#delete(java.lang.Iterable)
|
||||
*/
|
||||
@Override
|
||||
public void delete(Iterable<? extends T> entities) {
|
||||
public void deleteAll(Iterable<? extends T> entities) {
|
||||
|
||||
for (T entity : entities) {
|
||||
delete(entity);
|
||||
|
||||
Reference in New Issue
Block a user