DATAMONGO-1979 - Polishing.

Rename QueryUtils method to decorateSort(…) to reflect the nature of the method. Add missing generics. Convert ReactiveMongoRepositoryTests to AssertJ. Add missing verifyComplete() steps to StepVerifier. Slight tweaks to Javadoc and reference docs.

Original pull request: #566.
This commit is contained in:
Mark Paluch
2018-06-07 09:57:51 +02:00
parent 8f11916014
commit 794b026f73
9 changed files with 43 additions and 40 deletions

View File

@@ -13,6 +13,7 @@
* Tailable cursors for imperative driver.
* <<mongo.sessions, MongoDB 3.6 Session>> support for the imperative and reactive Template APIs.
* <<mongo.transactions, MongoDB 4.0 Transaction>> support and a MongoDB-specific transaction manager implementation.
* <<mongodb.repositories.queries.sort,Default sort specifications for repository query methods>> using `@Query(sort=…)`.
[[new-features.2-0-0]]
== What's New in Spring Data MongoDB 2.0

View File

@@ -398,9 +398,9 @@ The query in the preceding example returns only the `firstname`, `lastname` and
[[mongodb.repositories.queries.sort]]
=== Sorting Query Method results
When it comes to sorting MongoDB query results via the repository interface there are several options as listed below.
MongoDB repositories allow various approaches to define sorting order. Let's take a look at the following example:
.Sorting query results
.Sorting Query Results
====
[source,java]
----
@@ -417,10 +417,10 @@ public interface PersonRepository extends MongoRepository<Person, String> {
List<Person> findByLastname(String lastname, Sort sort); <4>
}
----
<1> Fixed sorting derived from method name. `SortByAgeDesc` results in `{ age : -1 }` sort parameter.
<2> Dynamic sorting via method argument. `Sort.by(DESC, "age")` creates a `{ age : -1 }` sort parameter.
<3> Fixed sorting via `Query` annotation. Sort parameter applied as stated in the `sort` attribute.
<4> Default sorting via `Query` annotation combined with dynamic one via method argument. `Sort.unsorted()`
<1> Static sorting derived from method name. `SortByAgeDesc` results in `{ age : -1 }` for the sort parameter.
<2> Dynamic sorting using a method argument. `Sort.by(DESC, "age")` creates `{ age : -1 }` for the sort parameter.
<3> Static sorting via `Query` annotation. Sort parameter applied as stated in the `sort` attribute.
<4> Default sorting via `Query` annotation combined with dynamic one via a method argument. `Sort.unsorted()`
results in `{ age : -1 }`. Using `Sort.by(ASC, "age")` overrides the defaults and creates `{ age : 1 }`. `Sort.by
(ASC, "firstname")` alters the default and results in `{ age : -1, firstname : 1 }`.
====