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.domain;
import java.io.Serializable;
import java.time.temporal.TemporalAccessor;
import java.util.Optional;
@@ -27,7 +26,7 @@ import java.util.Optional;
* @param <ID> the type of the audited type's identifier
* @author Oliver Gierke
*/
public interface Auditable<U, ID extends Serializable, T extends TemporalAccessor> extends Persistable<ID> {
public interface Auditable<U, ID, T extends TemporalAccessor> extends Persistable<ID> {
/**
* Returns the user who created this entity.

View File

@@ -15,15 +15,13 @@
*/
package org.springframework.data.domain;
import java.io.Serializable;
/**
* Simple interface for entities.
*
* @param <ID> the type of the identifier
* @author Oliver Gierke
*/
public interface Persistable<ID extends Serializable> extends Serializable {
public interface Persistable<ID> {
/**
* Returns the id of the entity.