DATACASS-525 - Polishing.

Add documentation for query methods allowing filtering (WITH ALLOW FILTERING).
This commit is contained in:
Mark Paluch
2018-02-14 14:32:53 +01:00
parent 847deccccc
commit 5760afd958
2 changed files with 8 additions and 0 deletions

View File

@@ -189,6 +189,9 @@ public interface PersonRepository extends CrudRepository<Person, String> {
Person findFirstByShippingAddress(Address address); <6>
Stream<Person> findAllBy(); <7>
@AllowFiltering
List<Person> findAllByAge(int age); <8>
}
----
<1> The method shows a query for all people with the given `lastname`. The query will be derived from parsing
@@ -203,6 +206,7 @@ in `CustomConversions`. Throws `IncorrectResultSizeDataAccessException` if more
<6> Uses the `First` keyword to restrict the query to the very first result. Unlike 5, this method does
not throw an exception if more than one match was found.
<7> Uses a Java 8 `Stream` which reads and converts individual elements while iterating the stream.
<8> Shows a query method annotated with `@AllowFiltering` that allows server-side filtering.
====
NOTE: Querying non-primary key properties requires secondary indexes.

View File

@@ -83,12 +83,16 @@ public interface ReactivePersonRepository extends ReactiveSortingRepository<Pers
Mono<Person> findByFirstnameAndLastname(String firstname, String lastname); <3>
Mono<Person> findFirstByFirstname(String firstname); <4>
@AllowFiltering
Flux<Person> findByAge(int age); <5>
}
----
<1> The method shows a query for all people with the given firstname. The query will be derived parsing the method name for constraints which can be concatenated with And and Or. Thus the method name will result in a query expression of `SELECT * FROM person WHERE firstname = :firstname`.
<2> The method shows a query for all people with the given firstname once the firstname is emitted via the given `Publisher`.
<3> Find a single entity for given criteria. Completes with `IncorrectResultSizeDataAccessException` on non unique results.
<4> Unlike 3, the first entity is always emitted even if the query yields more result rows.
<5> Shows a query method annotated with `@AllowFiltering` that allows server-side filtering.
====
For JavaConfig, use the `@EnableReactiveCassandraRepositories` annotation. The annotation carries the very same attributes