DATACMNS-944 - Moved to more consistent naming scheme for CrudRepository methods.

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(…)

That results in the following renames:

* findOne(…) -> findById(…)
* save(Iterable) -> saveAll(Iterable)
* findAll(Iterable<ID>) -> findAllById(…)
* delete(ID) -> deleteById(ID)
* delete(Iterable<T>) -> deleteAll(Iterable<T>)
* exists() -> existsById(…)

As a side-effect of that, we can now drop the Serializable requirement for identifiers.

Updated CRUD method detection to use the new naming scheme and moved the code to Java 8 streams and Optional. Adapted RepositoryInvoker API to reflect method name changes as well.
This commit is contained in:
Oliver Gierke
2017-04-28 15:28:28 +02:00
parent 382c912111
commit 727ab8384c
55 changed files with 324 additions and 397 deletions

View File

@@ -15,7 +15,6 @@
*/
package org.springframework.data.querydsl;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Optional;
@@ -112,22 +111,22 @@ public class QuerydslRepositoryInvokerAdapter implements RepositoryInvoker {
return delegate.hasSaveMethod();
}
/*
/*
* (non-Javadoc)
* @see org.springframework.data.repository.support.RepositoryInvoker#invokeDelete(java.io.Serializable)
* @see org.springframework.data.repository.support.RepositoryInvoker#invokeDeleteById(java.lang.Object)
*/
@Override
public void invokeDelete(Serializable id) {
delegate.invokeDelete(id);
public void invokeDeleteById(Object id) {
delegate.invokeDeleteById(id);
}
/*
/*
* (non-Javadoc)
* @see org.springframework.data.repository.support.RepositoryInvoker#invokeFindOne(java.io.Serializable)
* @see org.springframework.data.repository.support.RepositoryInvoker#invokeFindById(java.lang.Object)
*/
@Override
public <T> Optional<T> invokeFindOne(Serializable id) {
return delegate.invokeFindOne(id);
public <T> Optional<T> invokeFindById(Object id) {
return delegate.invokeFindById(id);
}
/*