diff --git a/src/docbkx/repositories.xml b/src/docbkx/repositories.xml index a97899b7a..6560aecf6 100644 --- a/src/docbkx/repositories.xml +++ b/src/docbkx/repositories.xml @@ -319,12 +319,14 @@ interface UserRepository extends MyBaseRepository<User, Long> { The query builder mechanism built into Spring Data repository infrastructure is useful to build constraining queries over entities - of the repository. We will strip the prefixes findBy, - find, readBy, read, - getBy as well as get from the method and - start parsing the rest of it. At a very basic level you can define - conditions on entity properties and concatenate them with - AND and OR. + of the repository. We will strip the prefixes find…By, + read…By, as well as get…By from the method + and start parsing the rest of it. The introducing clause can contain + further expressions such as a Distinct to set a distinct + flag on the query to be created. However, the first By + acts as delimiter to indicate the start of the actual criterias. At a + very basic level you can define conditions on entity properties and + concatenate them with AND and OR. Query creation from method names @@ -332,6 +334,19 @@ interface UserRepository extends MyBaseRepository<User, Long> { public interface PersonRepository extends Repository<User, Long> { List<Person> findByEmailAddressAndLastname(EmailAddress emailAddress, String lastname); + + // Enables the distinct flag for the query + List<Person> findDistinctPeopleByLastnameOrFirstname(String lastname, String firstname); + List<Person> findPeopleDistinctByLastnameOrFirstname(String lastname, String firstname); + + // Enabling ignoring case for an individual property + List<Person> findByLastnameIgnoreCase(String lastname); + // Enabling ignoring case for all suitable properties + List<Person> findByLastnameAndFirstnameAllIgnoreCase(String lastname, String firstname); + + // Enabling static ORDER BY for a query + List<Person> findByLastnameOrderByFirstnameAsc(String lastname); + List<Person> findByLastnameOrderByFirstnameDesc(String lastname); } @@ -347,6 +362,23 @@ interface UserRepository extends MyBaseRepository<User, Long> { datastore to datastore please consult the according part of the reference documentation. + As you can see the method parser also supports setting an ignore + case flag for individual properties (e.g. + findByLastnameIgnoreCase(…)) or for all + properties of a type that support ignoring case (i.e. usually + Strings, e.g. + findByLastnameAndFirstnameAllIgnoreCase(…)). + Whether ignoring cases is supported my differ from store to store, so + consult the relevant sections of the store specific query method + reference docs. + + Static ordering can be applied by appending an + OrderBy clause to the query method referencing a property + and providing a sorting direction (Asc or + Desc). To create a query method that supports dynamic + sorting have a look at . +
Property expressions