DATAMONGO-1311 - Polishing.

Update Javadoc and add reference documentation.
Alter @Meta batchSize default to zero, as negative values bear a special meaning.
Along the lines remove deprecated driver method usage and add deprecations for options about the be removed in subsequent MongoDB server releases.

Original Pull Request: #575
This commit is contained in:
Christoph Strobl
2018-06-29 10:15:21 +02:00
parent d3976f5199
commit 30b86e7612
13 changed files with 183 additions and 241 deletions

View File

@@ -1761,6 +1761,35 @@ GeoResults<Jedi> results = mongoOps.query(SWCharacter.class)
----
====
[[mongo.query.additional-query-options]]
=== Additional Query Options
MongoDB offers various ways of applying meta information, like a comment or a batch size, to a query. Using the `Query` API
directly there are several methods for those options.
====
[source,java]
----
Query query = query(where("firstname").is("luke"))
.comment("find luke") <1>
.batchSize(100) <2>
.slaveOk(); <3>
----
<1> The comment propagated to the MongoDB profile log.
<2> The number of documents to return in each response batch.
<3> Allows querying a replica slave.
====
On the repository level the `@Meta` annotation provides means to add query options in a declarative way.
====
[source,java]
----
@Meta(comment = "find luke", batchSize = 100, flags = { SLAVE_OK })
List<Person> findByFirstname(String firstname);
----
====
include::../{spring-data-commons-docs}/query-by-example.adoc[leveloffset=+1]
include::query-by-example.adoc[leveloffset=+1]