Browse Source

DATAMONGO-2598 - Wording changes.

Removed the language of oppression and violence
and replaced it with more neutral language.

Note that problematic words in the code have
to remain in the docs until the code changes.

Original pull request: #872.
pull/880/head
Jay Bryant 6 years ago committed by Mark Paluch
parent
commit
6a43f28466
No known key found for this signature in database
GPG Key ID: 51A00FA751B91849
  1. 2
      src/main/asciidoc/new-features.adoc
  2. 4
      src/main/asciidoc/reference/change-streams.adoc
  3. 8
      src/main/asciidoc/reference/client-session-transactions.adoc
  4. 2
      src/main/asciidoc/reference/jmx.adoc
  5. 3
      src/main/asciidoc/reference/mapping.adoc
  6. 2
      src/main/asciidoc/reference/mongo-repositories-aggregation.adoc
  7. 58
      src/main/asciidoc/reference/mongodb.adoc
  8. 2
      src/main/asciidoc/reference/query-by-example.adoc
  9. 2
      src/main/asciidoc/reference/reactive-mongo-repositories.adoc
  10. 14
      src/main/asciidoc/reference/reactive-mongodb.adoc
  11. 4
      src/main/asciidoc/reference/tailable-cursors.adoc

2
src/main/asciidoc/new-features.adoc

@ -44,7 +44,7 @@ @@ -44,7 +44,7 @@
[[new-features.2-1-0]]
== What's New in Spring Data MongoDB 2.1
* Cursor-based aggregation execution.
* Cursor-based aggregation.
* <<mongo-template.query.distinct,Distinct queries>> for imperative and reactive Template APIs.
* Support for Map/Reduce through the reactive Template API.
* <<mongo.mongo-3.validation,`validator` support for collections>>.

4
src/main/asciidoc/reference/change-streams.adoc

@ -16,7 +16,7 @@ In doubt, use `Document`. @@ -16,7 +16,7 @@ In doubt, use `Document`.
Listening to a https://docs.mongodb.com/manual/tutorial/change-streams-example/[Change Stream by using a Sync Driver] creates a long running, blocking task that needs to be delegated to a separate component.
In this case, we need to first create a `MessageListenerContainer`, which will be the main entry point for running the specific `SubscriptionRequest` tasks.
Spring Data MongoDB already ships with a default implementation that operates on `MongoTemplate` and is capable of creating and executing `Task` instances for a `ChangeStreamRequest`.
Spring Data MongoDB already ships with a default implementation that operates on `MongoTemplate` and is capable of creating and running `Task` instances for a `ChangeStreamRequest`.
The following example shows how to use Change Streams with `MessageListener` instances:
@ -39,7 +39,7 @@ container.stop(); @@ -39,7 +39,7 @@ container.stop();
<1> Starting the container initializes the resources and starts `Task` instances for already registered `SubscriptionRequest` instances. Requests added after startup are ran immediately.
<2> Define the listener called when a `Message` is received. The `Message#getBody()` is converted to the requested domain type. Use `Document` to receive raw results without conversion.
<3> Set the collection to listen to and provide additional options through `ChangeStreamOptions`.
<4> Register the request. The returned `Subscription` can be used to check the current `Task` state and cancel its execution to free resources.
<4> Register the request. The returned `Subscription` can be used to check the current `Task` state and cancel it to free resources.
<5> Do not forget to stop the container once you are sure you no longer need it. Doing so stops all running `Task` instances within the container.
====

8
src/main/asciidoc/reference/client-session-transactions.adoc

@ -221,7 +221,7 @@ NOTE: `@Transactional(readOnly = true)` advises `MongoTransactionManager` to als @@ -221,7 +221,7 @@ NOTE: `@Transactional(readOnly = true)` advises `MongoTransactionManager` to als
== Reactive Transactions
Same as with the reactive `ClientSession` support, the `ReactiveMongoTemplate` offers dedicated methods for operating
within a transaction without having to worry about the commit/abort actions depending on the operations outcome.
within a transaction without having to worry about the committing or stopping actions depending on the operations outcome.
NOTE: Unless you specify a `ReactiveMongoTransactionManager` within your application context, transaction support is *DISABLED*. You can use `setSessionSynchronization(ALWAYS)` to participate in ongoing non-native MongoDB transactions.
@ -249,7 +249,7 @@ Mono<DeleteResult> result = Mono @@ -249,7 +249,7 @@ Mono<DeleteResult> result = Mono
<1> First we obviously need to initiate the session.
<2> Once we have the `ClientSession` at hand, start the transaction.
<3> Operate within the transaction by passing on the `ClientSession` to the operation.
<4> If the operations completes exceptionally, we need to abort the transaction and preserve the error.
<4> If the operations completes exceptionally, we need to stop the transaction and preserve the error.
<5> Or of course, commit the changes in case of success. Still preserving the operations result.
<6> Lastly, we need to make sure to close the session.
====
@ -339,7 +339,7 @@ Inside transactions, MongoDB server has a slightly different behavior. @@ -339,7 +339,7 @@ Inside transactions, MongoDB server has a slightly different behavior.
*Connection Settings*
The MongoDB drivers offer a dedicated replica set name configuration option turing the driver into auto detection
mode. This option helps identifying replica set master nodes and command routing during a transaction.
mode. This option helps identifying replica set manager nodes and command routing during a transaction.
NOTE: Make sure to add `replicaSet` to the MongoDB URI. Please refer to https://docs.mongodb.com/manual/reference/connection-string/#connections-connection-options[connection string options] for further details.
@ -351,7 +351,7 @@ structures in place. @@ -351,7 +351,7 @@ structures in place.
*Transient Errors*
MongoDB can add special labels to errors raised during transactional execution. Those may indicate transient failures
MongoDB can add special labels to errors raised during transactional operations. Those may indicate transient failures
that might vanish by merely retrying the operation.
We highly recommend https://github.com/spring-projects/spring-retry[Spring Retry] for those purposes. Nevertheless
one may override `MongoTransactionManager#doCommit(MongoTransactionObject)` to implement a https://docs.mongodb.com/manual/core/transactions/#retry-commit-operation[Retry Commit Operation]

2
src/main/asciidoc/reference/jmx.adoc

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
[[mongo.jmx]]
= JMX support
The JMX support for MongoDB exposes the results of executing the 'serverStatus' command on the admin database for a single MongoDB server instance. It also exposes an administrative MBean, `MongoAdmin`, that lets you perform administrative operations, such as dropping or creating a database. The JMX features build upon the JMX feature set available in the Spring Framework. See https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/integration.html#jmx[here] for more details.
The JMX support for MongoDB exposes the results of running the 'serverStatus' command on the admin database for a single MongoDB server instance. It also exposes an administrative MBean, `MongoAdmin`, that lets you perform administrative operations, such as dropping or creating a database. The JMX features build upon the JMX feature set available in the Spring Framework. See https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/integration.html#jmx[here] for more details.
[[mongodb:jmx-configuration]]
== MongoDB JMX Configuration

3
src/main/asciidoc/reference/mapping.adoc

@ -548,6 +548,7 @@ public class Person<T extends Address> { @@ -548,6 +548,7 @@ public class Person<T extends Address> {
}
// other getters/setters omitted
}
----
[TIP]
@ -784,7 +785,7 @@ class Nested { @@ -784,7 +785,7 @@ class Nested {
[[mapping-usage-references]]
=== Using DBRefs
The mapping framework does not have to store child objects embedded within the document. You can also store them separately and use a DBRef to refer to that document. When the object is loaded from MongoDB, those references are eagerly resolved so that you get back a mapped object that looks the same as if it had been stored embedded within your master document.
The mapping framework does not have to store child objects embedded within the document. You can also store them separately and use a DBRef to refer to that document. When the object is loaded from MongoDB, those references are eagerly resolved so that you get back a mapped object that looks the same as if it had been stored embedded within your controlling document.
The following example uses a DBRef to refer to a specific document that exists independently of the object in which it is referenced (both classes are shown in-line for brevity's sake):

2
src/main/asciidoc/reference/mongo-repositories-aggregation.adoc

@ -73,7 +73,7 @@ To gain more control, you might consider `AggregationResult` as method return ty @@ -73,7 +73,7 @@ To gain more control, you might consider `AggregationResult` as method return ty
<8> Like in <6>, a single value can be directly obtained from multiple result ``Document``s.
====
In some scenarios aggregations might require additional options like a maximum execution time, additional log comments or the permission to temporarily write data to disk.
In some scenarios, aggregations might require additional options, such as a maximum run time, additional log comments, or the permission to temporarily write data to disk.
Use the `@Meta` annotation to set those options via `maxExecutionTimeMs`, `comment` or `allowDiskUse`.
[source,java]

58
src/main/asciidoc/reference/mongodb.adoc

@ -417,7 +417,7 @@ The default converter implementation used by `MongoTemplate` is `MappingMongoCon @@ -417,7 +417,7 @@ The default converter implementation used by `MongoTemplate` is `MappingMongoCon
Another central feature of `MongoTemplate` is translation of exceptions thrown by the MongoDB Java driver into Spring's portable Data Access Exception hierarchy. See "`<<mongo.exception>>`" for more information.
`MongoTemplate` offers many convenience methods to help you easily perform common tasks. However, if you need to directly access the MongoDB driver API, you can use one of several `Execute` callback methods. The execute callbacks gives you a reference to either a `com.mongodb.client.MongoCollection` or a `com.mongodb.client.MongoDatabase` object. See the <<mongo.executioncallback,"`Execution Callbacks`">> section for more information.
`MongoTemplate` offers many convenience methods to help you easily perform common tasks. However, if you need to directly access the MongoDB driver API, you can use one of several `Execute` callback methods. The `execute` callbacks gives you a reference to either a `com.mongodb.client.MongoCollection` or a `com.mongodb.client.MongoDatabase` object. See the <<mongo.executioncallback,"`Execution Callbacks`">> section for more information.
The next section contains an example of how to work with the `MongoTemplate` in the context of the Spring container.
@ -875,7 +875,7 @@ In addition to the `Query` discussed earlier, we provide the update definition b @@ -875,7 +875,7 @@ In addition to the `Query` discussed earlier, we provide the update definition b
Most methods return the `Update` object to provide a fluent style for the API.
[[mongodb-template-update.methods]]
==== Methods for Executing Updates for Documents
==== Methods for Running Updates for Documents
* *updateFirst*: Updates the first document that matches the query document criteria with the updated document.
* *updateMulti*: Updates all objects that match the query document criteria with the updated document.
@ -1054,7 +1054,7 @@ db.students.update( <3> @@ -1054,7 +1054,7 @@ db.students.update( <3>
----
<1> The 1st `$set` stage calculates a new field _average_ based on the average of the _tests_ field.
<2> The 2nd `$set` stage calculates a new field _grade_ based on the _average_ field calculated by the first aggregation stage.
<3> The pipeline is executed on the _students_ collection and uses `Student` for the aggregation field mapping.
<3> The pipeline is run on the _students_ collection and uses `Student` for the aggregation field mapping.
<4> Apply the update to all matching documents in the collection.
====
@ -1080,7 +1080,7 @@ Optional<User> result = template.update(Person.class) <1> @@ -1080,7 +1080,7 @@ Optional<User> result = template.update(Person.class) <1>
<2> The actual match query mapped against the given domain type. Provide `sort`, `fields` and `collation` settings via the query.
<3> Additional optional hook to provide options other than the defaults, like `upsert`.
<4> An optional projection type used for mapping the operation result. If none given the initial domain type is used.
<5> Trigger the actual execution. Use `findAndReplaceValue` to obtain the nullable result instead of an `Optional`.
<5> Trigger the actual processing. Use `findAndReplaceValue` to obtain the nullable result instead of an `Optional`.
====
IMPORTANT: Please note that the replacement must not hold an `id` itself as the `id` of the existing `Document` will be
@ -1107,7 +1107,7 @@ template.findAllAndRemove(new Query().limit(3), "GOT"); <5> @@ -1107,7 +1107,7 @@ template.findAllAndRemove(new Query().limit(3), "GOT"); <5>
----
<1> Remove a single entity specified by its `_id` from the associated collection.
<2> Remove all documents that match the criteria of the query from the `GOT` collection.
<3> Remove the first three documents in the `GOT` collection. Unlike <2>, the documents to remove are identified by their `_id`, executing the given query, applying `sort`, `limit`, and `skip` options first, and then removing all at once in a separate step.
<3> Remove the first three documents in the `GOT` collection. Unlike <2>, the documents to remove are identified by their `_id`, running the given query, applying `sort`, `limit`, and `skip` options first, and then removing all at once in a separate step.
<4> Remove all documents matching the criteria of the query from the `GOT` collection. Unlike <3>, documents do not get deleted in a batch but one by one.
<5> Remove the first three documents in the `GOT` collection. Unlike <3>, documents do not get deleted in a batch but one by one.
====
@ -1521,7 +1521,7 @@ repo.findByLocationWithin( <4> @@ -1521,7 +1521,7 @@ repo.findByLocationWithin( <4>
new Polygon(
new Point(-73.992514, 40.758934),
new Point(-73.961138, 40.760348),
new Point(-73.991658, 40.730006));
new Point(-73.991658, 40.730006)));
----
<1> Repository method definition using the commons type allows calling it with both the GeoJSON and the legacy format.
<2> Use GeoJSON type to make use of `$geometry` operator.
@ -1724,7 +1724,7 @@ db.foo.createIndex( @@ -1724,7 +1724,7 @@ db.foo.createIndex(
)
----
A query searching for `coffee cake` can be defined and executed as follows:
A query searching for `coffee cake` can be defined and run as follows:
.Full Text Query
====
@ -1808,7 +1808,7 @@ collation is applied to index creation and queries unless you specify a differen @@ -1808,7 +1808,7 @@ collation is applied to index creation and queries unless you specify a differen
whole operation and cannot be specified on a per-field basis.
Like other metadata, collations can be be derived from the domain type via the `collation` attribute of the `@Document`
annotation and will be applied directly when executing queries, creating collections or indexes.
annotation and will be applied directly when running queries, creating collections or indexes.
NOTE: Annotated collations will not be used when a collection is auto created by MongoDB on first interaction. This would
require additional store interaction delaying the entire process. Please use `MongoOperations.createCollection` for those cases.
@ -2125,7 +2125,7 @@ target type is a closed interface or DTO projection. @@ -2125,7 +2125,7 @@ target type is a closed interface or DTO projection.
You can switch between retrieving a single entity and retrieving multiple entities as a `List` or a `Stream` through the terminating methods: `first()`, `one()`, `all()`, or `stream()`.
When writing a geo-spatial query with `near(NearQuery)`, the number of terminating methods is altered to include only the methods that are valid for executing a `geoNear` command in MongoDB (fetching entities as a `GeoResult` within `GeoResults`), as the following example shows:
When writing a geo-spatial query with `near(NearQuery)`, the number of terminating methods is altered to include only the methods that are valid for running a `geoNear` command in MongoDB (fetching entities as a `GeoResult` within `GeoResults`), as the following example shows:
====
[source,java]
@ -2224,7 +2224,7 @@ As of Spring Data MongoDB 3.x any `count` operation uses regardless the existenc @@ -2224,7 +2224,7 @@ As of Spring Data MongoDB 3.x any `count` operation uses regardless the existenc
[NOTE]
====
MongoDBs native `countDocuments` method, and the executed `$match` aggregation, does not support `$near` and `$nearSphere` but require `$geoWithin` along with `$center` or `$centerSphere` which does not support `$minDistance` (see https://jira.mongodb.org/browse/SERVER-37043).
MongoDBs native `countDocuments` method and the `$match` aggregation, do not support `$near` and `$nearSphere` but require `$geoWithin` along with `$center` or `$centerSphere` which does not support `$minDistance` (see https://jira.mongodb.org/browse/SERVER-37043).
Therefore a given `Query` will be rewritten for `count` operations using `Reactive`-/`MongoTemplate` to bypass the issue like shown below.
@ -2247,7 +2247,7 @@ Therefore a given `Query` will be rewritten for `count` operations using `Reacti @@ -2247,7 +2247,7 @@ Therefore a given `Query` will be rewritten for `count` operations using `Reacti
You can query MongoDB by using Map-Reduce, which is useful for batch processing, for data aggregation, and for when the query language does not fulfill your needs.
Spring provides integration with MongoDB's Map-Reduce by providing methods on `MongoOperations` to simplify the creation and execution of Map-Reduce operations.It can convert the results of a Map-Reduce operation to a POJO and integrates with Spring's https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/core.html#resources[Resource abstraction].This lets you place your JavaScript files on the file system, classpath, HTTP server, or any other Spring Resource implementation and then reference the JavaScript resources through an easy URI style syntax -- for example, `classpath:reduce.js;`.Externalizing JavaScript code in files is often preferable to embedding them as Java strings in your code.Note that you can still pass JavaScript code as Java strings if you prefer.
Spring provides integration with MongoDB's Map-Reduce by providing methods on `MongoOperations` to simplify the creation and running of Map-Reduce operations.It can convert the results of a Map-Reduce operation to a POJO and integrates with Spring's https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/core.html#resources[Resource abstraction].This lets you place your JavaScript files on the file system, classpath, HTTP server, or any other Spring Resource implementation and then reference the JavaScript resources through an easy URI style syntax -- for example, `classpath:reduce.js;`.Externalizing JavaScript code in files is often preferable to embedding them as Java strings in your code.Note that you can still pass JavaScript code as Java strings if you prefer.
[[mongo.mapreduce.example]]
=== Example Usage
@ -2379,7 +2379,7 @@ by `ScriptOperations`. + @@ -2379,7 +2379,7 @@ by `ScriptOperations`. +
There is no replacement for the removed functionality.
====
MongoDB allows executing JavaScript functions on the server by either directly sending the script or calling a stored one. `ScriptOperations` can be accessed through `MongoTemplate` and provides basic abstraction for `JavaScript` usage. The following example shows how to us the `ScriptOperations` class:
MongoDB allows running JavaScript functions on the server by either directly sending the script or calling a stored one. `ScriptOperations` can be accessed through `MongoTemplate` and provides basic abstraction for `JavaScript` usage. The following example shows how to us the `ScriptOperations` class:
====
[source,java]
@ -2392,9 +2392,9 @@ scriptOps.execute(echoScript, "directly execute script"); <1> @@ -2392,9 +2392,9 @@ scriptOps.execute(echoScript, "directly execute script"); <1>
scriptOps.register(new NamedMongoScript("echo", echoScript)); <2>
scriptOps.call("echo", "execute script via name"); <3>
----
<1> Execute the script directly without storing the function on server side.
<1> Run the script directly without storing the function on server side.
<2> Store the script using 'echo' as its name. The given name identifies the script and allows calling it later.
<3> Execute the script with name 'echo' using the provided parameters.
<3> Run the script with name 'echo' using the provided parameters.
====
[[mongo.group]]
@ -2402,7 +2402,7 @@ scriptOps.call("echo", "execute script via name"); <3> @@ -2402,7 +2402,7 @@ scriptOps.call("echo", "execute script via name"); <3>
As an alternative to using Map-Reduce to perform data aggregation, you can use the https://www.mongodb.org/display/DOCS/Aggregation#Aggregation-Group[`group` operation] which feels similar to using SQL's group by query style, so it may feel more approachable vs. using Map-Reduce. Using the group operations does have some limitations, for example it is not supported in a shared environment and it returns the full result set in a single BSON object, so the result should be small, less than 10,000 keys.
Spring provides integration with MongoDB's group operation by providing methods on MongoOperations to simplify the creation and execution of group operations. It can convert the results of the group operation to a POJO and also integrates with Spring's https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/core.html#resources[Resource abstraction] abstraction. This will let you place your JavaScript files on the file system, classpath, http server or any other Spring Resource implementation and then reference the JavaScript resources via an easy URI style syntax, e.g. 'classpath:reduce.js;. Externalizing JavaScript code in files if often preferable to embedding them as Java strings in your code. Note that you can still pass JavaScript code as Java strings if you prefer.
Spring provides integration with MongoDB's group operation by providing methods on MongoOperations to simplify the creation and running of group operations. It can convert the results of the group operation to a POJO and also integrates with Spring's https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/core.html#resources[Resource abstraction] abstraction. This will let you place your JavaScript files on the file system, classpath, http server or any other Spring Resource implementation and then reference the JavaScript resources via an easy URI style syntax, e.g. 'classpath:reduce.js;. Externalizing JavaScript code in files if often preferable to embedding them as Java strings in your code. Note that you can still pass JavaScript code as Java strings if you prefer.
[[mongo.group.example]]
=== Example Usage
@ -2419,7 +2419,7 @@ In order to understand how group operations work the following example is used, @@ -2419,7 +2419,7 @@ In order to understand how group operations work the following example is used,
{ "_id" : ObjectId("4ec1d25d41421e2015da64f6"), "x" : 3 }
----
We would like to group by the only field in each row, the `x` field and aggregate the number of times each specific value of `x` occurs. To do this we need to create an initial document that contains our count variable and also a reduce function which will increment it each time it is encountered. The Java code to execute the group operation is shown below
We would like to group by the only field in each row, the `x` field and aggregate the number of times each specific value of `x` occurs. To do this we need to create an initial document that contains our count variable and also a reduce function which will increment it each time it is encountered. The Java code to run the group operation is shown below
[source,java]
----
@ -2508,13 +2508,13 @@ The Aggregation Framework support in Spring Data MongoDB is based on the followi @@ -2508,13 +2508,13 @@ The Aggregation Framework support in Spring Data MongoDB is based on the followi
+
An `Aggregation` represents a MongoDB `aggregate` operation and holds the description of the aggregation pipeline instructions. Aggregations are created by invoking the appropriate `newAggregation(…)` static factory method of the `Aggregation` class, which takes a list of `AggregateOperation` and an optional input class.
+
The actual aggregate operation is executed by the `aggregate` method of the `MongoTemplate`, which takes the desired output class as a parameter.
The actual aggregate operation is run by the `aggregate` method of the `MongoTemplate`, which takes the desired output class as a parameter.
+
* `TypedAggregation`
+
A `TypedAggregation`, just like an `Aggregation`, holds the instructions of the aggregation pipeline and a reference to the input type, that is used for mapping domain properties to actual document fields.
+
On execution field references get checked against the given input type considering potential `@Field` annotations and raising errors when referencing non existing properties.
At runtime, field references get checked against the given input type, considering potential `@Field` annotations and raising errors when referencing nonexistent properties.
+
* `AggregationOperation`
+
@ -2755,7 +2755,7 @@ A sort by count operation is equivalent to the following BSON (Binary JSON): @@ -2755,7 +2755,7 @@ A sort by count operation is equivalent to the following BSON (Binary JSON):
[[mongo.aggregation.projection.expressions]]
==== Spring Expression Support in Projection Expressions
We support the use of SpEL expressions in projection expressions through the `andExpression` method of the `ProjectionOperation` and `BucketOperation` classes. This feature lets you define the desired expression as a SpEL expression. On query execution, the SpEL expression is translated into a corresponding MongoDB projection expression part. This arrangement makes it much easier to express complex calculations.
We support the use of SpEL expressions in projection expressions through the `andExpression` method of the `ProjectionOperation` and `BucketOperation` classes. This feature lets you define the desired expression as a SpEL expression. On running a query, the SpEL expression is translated into a corresponding MongoDB projection expression part. This arrangement makes it much easier to express complex calculations.
===== Complex Calculations with SpEL expressions
@ -3226,16 +3226,16 @@ mongoTemplate.dropCollection("MyNewCollection"); @@ -3226,16 +3226,16 @@ mongoTemplate.dropCollection("MyNewCollection");
NOTE: Collection creation allows customization with `CollectionOptions` and supports <<mongo.collation,collations>>.
[[mongo-template.commands]]
== Executing Commands
== Running Commands
You can get at the MongoDB driver's `MongoDatabase.runCommand( )` method by using the `executeCommand(…)` methods on `MongoTemplate`. These methods also perform exception translation into Spring's `DataAccessException` hierarchy.
[[mongo-template.commands.execution]]
=== Methods for executing commands
=== Methods for running commands
* `Document` *executeCommand* `(Document command)`: Run a MongoDB command.
* `Document` *executeCommand* `(Document command, ReadPreference readPreference)`: Run a MongoDB command with the given nullable MongoDB `ReadPreference`.
* `Document` *executeCommand* `(String jsonCommand)`: Execute a MongoDB command expressed as a JSON string.
* `Document` *executeCommand* `(String jsonCommand)`: Run a MongoDB command expressed as a JSON string.
[[mongodb.mapping-usage.events]]
== Lifecycle Events
@ -3299,19 +3299,19 @@ Some of the mappings performed by the `MongoExceptionTranslator` are `com.mongod @@ -3299,19 +3299,19 @@ Some of the mappings performed by the `MongoExceptionTranslator` are `com.mongod
[[mongo.executioncallback]]
== Execution Callbacks
One common design feature of all Spring template classes is that all functionality is routed into one of the template's execute callback methods. Doing so helps to ensure that exceptions and any resource management that may be required are performed consistently. While JDBC and JMS need this feature much more than MongoDB does, it still offers a single spot for exception translation and logging to occur. Consequently, using these execute callbacks is the preferred way to access the MongoDB driver's `MongoDatabase` and `MongoCollection` objects to perform uncommon operations that were not exposed as methods on `MongoTemplate`.
One common design feature of all Spring template classes is that all functionality is routed into one of the template's `execute` callback methods. Doing so helps to ensure that exceptions and any resource management that may be required are performed consistently. While JDBC and JMS need this feature much more than MongoDB does, it still offers a single spot for exception translation and logging to occur. Consequently, using these `execute` callbacks is the preferred way to access the MongoDB driver's `MongoDatabase` and `MongoCollection` objects to perform uncommon operations that were not exposed as methods on `MongoTemplate`.
The following list describes the execute callback methods.
The following list describes the `execute` callback methods.
* `<T> T` *execute* `(Class<?> entityClass, CollectionCallback<T> action)`: Executes the given `CollectionCallback` for the entity collection of the specified class.
* `<T> T` *execute* `(Class<?> entityClass, CollectionCallback<T> action)`: Runs the given `CollectionCallback` for the entity collection of the specified class.
* `<T> T` *execute* `(String collectionName, CollectionCallback<T> action)`: Executes the given `CollectionCallback` on the collection of the given name.
* `<T> T` *execute* `(String collectionName, CollectionCallback<T> action)`: Runs the given `CollectionCallback` on the collection of the given name.
* `<T> T` *execute* `(DbCallback<T> action)`: Executes a DbCallback translating any exceptions as necessary. Spring Data MongoDB provides support for the Aggregation Framework introduced to MongoDB in version 2.2.
* `<T> T` *execute* `(DbCallback<T> action)`: Runs a DbCallback, translating any exceptions as necessary. Spring Data MongoDB provides support for the Aggregation Framework introduced to MongoDB in version 2.2.
* `<T> T` *execute* `(String collectionName, DbCallback<T> action)`: Executes a `DbCallback` on the collection of the given name translating any exceptions as necessary.
* `<T> T` *execute* `(String collectionName, DbCallback<T> action)`: Runs a `DbCallback` on the collection of the given name translating any exceptions as necessary.
* `<T> T` *executeInSession* `(DbCallback<T> action)`: Executes the given `DbCallback` within the same connection to the database so as to ensure consistency in a write-heavy environment where you may read the data that you wrote.
* `<T> T` *executeInSession* `(DbCallback<T> action)`: Runs the given `DbCallback` within the same connection to the database so as to ensure consistency in a write-heavy environment where you may read the data that you wrote.
The following example uses the `CollectionCallback` to return information about an index:

2
src/main/asciidoc/reference/query-by-example.adoc

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
[[query-by-example.execution]]
[[query-by-example.running]]
== Running an Example
The following example shows how to query by example when using a repository (of `Person` objects, in this case):

2
src/main/asciidoc/reference/reactive-mongo-repositories.adoc

@ -235,7 +235,7 @@ It provides the following features: @@ -235,7 +235,7 @@ It provides the following features:
See the http://www.querydsl.com/static/querydsl/latest/reference/html/[Querydsl documentation] for how to bootstrap your environment for APT-based code generation using Maven or Ant.
The Querydsl repository support lets you write and execute queries such as the following:
The Querydsl repository support lets you write and run queries, such as the following:
[source,java]
----

14
src/main/asciidoc/reference/reactive-mongodb.adoc

@ -19,7 +19,7 @@ For most tasks, you should use `ReactiveMongoTemplate` or the repository support @@ -19,7 +19,7 @@ For most tasks, you should use `ReactiveMongoTemplate` or the repository support
Spring MongoDB support requires MongoDB 2.6 or higher and Java SE 8 or higher.
First, you need to set up a running MongoDB server. Refer to the https://docs.mongodb.org/manual/core/introduction/[MongoDB Quick Start guide] for an explanation on how to startup a MongoDB instance. Once installed, starting MongoDB is typically a matter of executing the following command: `${MONGO_HOME}/bin/mongod`
First, you need to set up a running MongoDB server. Refer to the https://docs.mongodb.org/manual/core/introduction/[MongoDB Quick Start guide] for an explanation on how to startup a MongoDB instance. Once installed, starting MongoDB is typically a matter of running the following command: `${MONGO_HOME}/bin/mongod`
To create a Spring project in STS, go to File -> New -> Spring Template Project -> Simple Spring Utility Project and press Yes when prompted. Then enter a project and a package name, such as org.spring.mongodb.example.
@ -462,15 +462,15 @@ NOTE: The preceding example is meant to show the use of save, update, and remove @@ -462,15 +462,15 @@ NOTE: The preceding example is meant to show the use of save, update, and remove
[[mongo.reactive.executioncallback]]
== Execution Callbacks
One common design feature of all Spring template classes is that all functionality is routed into one of the templates execute callback methods. This helps ensure that exceptions and any resource management that maybe required are performed consistency. While this was of much greater need in the case of JDBC and JMS than with MongoDB, it still offers a single spot for exception translation and logging to occur. As such, using the execute callback is the preferred way to access the MongoDB driver's `MongoDatabase` and `MongoCollection` objects to perform uncommon operations that were not exposed as methods on `ReactiveMongoTemplate`.
One common design feature of all Spring template classes is that all functionality is routed into one of the templates that run callback methods. This helps ensure that exceptions and any resource management that maybe required are performed consistency. While this was of much greater need in the case of JDBC and JMS than with MongoDB, it still offers a single spot for exception translation and logging to occur. As such, using the `execute` callback is the preferred way to access the MongoDB driver's `MongoDatabase` and `MongoCollection` objects to perform uncommon operations that were not exposed as methods on `ReactiveMongoTemplate`.
Here is a list of execute callback methods.
Here is a list of `execute` callback methods.
* `<T> Flux<T>` *execute* `(Class<?> entityClass, ReactiveCollectionCallback<T> action)`: Executes the given `ReactiveCollectionCallback` for the entity collection of the specified class.
* `<T> Flux<T>` *execute* `(Class<?> entityClass, ReactiveCollectionCallback<T> action)`: Runs the given `ReactiveCollectionCallback` for the entity collection of the specified class.
* `<T> Flux<T>` *execute* `(String collectionName, ReactiveCollectionCallback<T> action)`: Executes the given `ReactiveCollectionCallback` on the collection of the given name.
* `<T> Flux<T>` *execute* `(String collectionName, ReactiveCollectionCallback<T> action)`: Runs the given `ReactiveCollectionCallback` on the collection of the given name.
* `<T> Flux<T>` *execute* `(ReactiveDatabaseCallback<T> action)`: Executes a `ReactiveDatabaseCallback` translating any exceptions as necessary.
* `<T> Flux<T>` *execute* `(ReactiveDatabaseCallback<T> action)`: Runs a `ReactiveDatabaseCallback` translating any exceptions as necessary.
The following example uses the `ReactiveCollectionCallback` to return information about an index:
@ -556,7 +556,7 @@ class ReactiveGridFsClient { @@ -556,7 +556,7 @@ class ReactiveGridFsClient {
NOTE: Currently, MongoDB does not support defining sort criteria when retrieving files from GridFS. For this reason, any sort criteria defined on the `Query` instance handed into the `find(…)` method are disregarded.
The other option to read files from the GridFs is to use the methods modeled along the lines of `ResourcePatternResolver`.
`ReactiveGridFsOperations` uses reactive types to defer execution while `ResourcePatternResolver` uses a synchronous interface.
`ReactiveGridFsOperations` uses reactive types to defer running while `ResourcePatternResolver` uses a synchronous interface.
These methods allow handing an Ant path into the method and can thus retrieve files matching the given pattern. The following example shows how to use `ReactiveGridFsTemplate` to read files:
.Using ReactiveGridFsTemplate to read files

4
src/main/asciidoc/reference/tailable-cursors.adoc

@ -19,7 +19,7 @@ concept that is already prevalent in the Spring ecosystem. @@ -19,7 +19,7 @@ concept that is already prevalent in the Spring ecosystem.
Listening to a capped collection using a Sync Driver creates a long running, blocking task that needs to be delegated to
a separate component. In this case, we need to first create a `MessageListenerContainer`, which will be the main entry point
for running the specific `SubscriptionRequest`. Spring Data MongoDB already ships with a default implementation that
operates on `MongoTemplate` and is capable of creating and executing `Task` instances for a `TailableCursorRequest`.
operates on `MongoTemplate` and is capable of creating and running `Task` instances for a `TailableCursorRequest`.
The following example shows how to use tailable cursors with `MessageListener` instances:
@ -49,7 +49,7 @@ container.stop(); @@ -49,7 +49,7 @@ container.stop();
<3> Set the collection to listen to.
<4> Provide an optional filter for documents to receive.
<5> Set the message listener to publish incoming ``Message``s to.
<6> Register the request. The returned `Subscription` can be used to check the current `Task` state and cancel its execution to free resources.
<6> Register the request. The returned `Subscription` can be used to check the current `Task` state and cancel it to free resources.
<5> Do not forget to stop the container once you are sure you no longer need it. Doing so stops all running `Task` instances within the container.
====

Loading…
Cancel
Save