Allow open/close projection on return type for findAndReplace.
Use default methods for delegation and remove collation from FindAndRemoveOption in favor of the collation set on the query itself.
Update Javadoc and reference documentation.
Original Pull Request: #569
@ -1072,60 +1072,33 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@@ -1072,60 +1072,33 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
// Find methods that take a Query to express the query and that return a single object that is also removed from the
@ -2661,30 +2634,38 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@@ -2661,30 +2634,38 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@ -2747,6 +2728,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@@ -2747,6 +2728,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@ -3102,37 +3084,53 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@@ -3102,37 +3084,53 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@ -1084,59 +1102,33 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@@ -1084,59 +1102,33 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@ -2481,28 +2473,41 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@@ -2481,28 +2473,41 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@ -2988,17 +2993,26 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@@ -2988,17 +2993,26 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@ -3010,7 +3024,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@@ -3010,7 +3024,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@ -3020,8 +3034,6 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@@ -3020,8 +3034,6 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@ -437,7 +437,7 @@ NOTE: Once configured, `MongoTemplate` is thread-safe and can be reused across m
@@ -437,7 +437,7 @@ NOTE: Once configured, `MongoTemplate` is thread-safe and can be reused across m
The mapping between MongoDB documents and domain classes is done by delegating to an implementation of the `MongoConverter` interface. Spring provides `MappingMongoConverter`, but you can also write your own converter. See "`<<mongo.custom-converters>>`" for more detailed information.
The `MongoTemplate` class implements the interface `MongoOperations`. In as much as possible, the methods on `MongoOperations` are named after methods available on the MongoDB driver `Collection` object, to make the API familiar to existing MongoDB developers who are used to the driver API. For example, you can find methods such as `find`, `findAndModify`, `findOne`, `insert`, `remove`, `save`, `update`, and `updateMulti`. The design goal was to make it as easy as possible to transition between the use of the base MongoDB driver and `MongoOperations`. A major difference between the two APIs is that `MongoOperations` can be passed domain objects instead of `Document`. Also, `MongoOperations` has fluent APIs for `Query`, `Criteria`, and `Update` operations instead of populating a `Document` to specify the parameters for those operations.
The `MongoTemplate` class implements the interface `MongoOperations`. In as much as possible, the methods on `MongoOperations` are named after methods available on the MongoDB driver `Collection` object, to make the API familiar to existing MongoDB developers who are used to the driver API. For example, you can find methods such as `find`, `findAndModify`, `findAndReplace`, `findOne`, `insert`, `remove`, `save`, `update`, and `updateMulti`. The design goal was to make it as easy as possible to transition between the use of the base MongoDB driver and `MongoOperations`. A major difference between the two APIs is that `MongoOperations` can be passed domain objects instead of `Document`. Also, `MongoOperations` has fluent APIs for `Query`, `Criteria`, and `Update` operations instead of populating a `Document` to specify the parameters for those operations.
NOTE: The preferred way to reference the operations on `MongoTemplate` instance is through its interface, `MongoOperations`.
<1> Use the fluent update API with the domain type given for mapping the query and deriving the collection name or just use `MongoOperations#findAndReplace`.
<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`.
====
IMPORTANT: Please note that the replacement must not hold an `id` itself as the `id` of the existing `Document` will be
carried over to the replacement by the store itself. Also keep in mind that `findAndReplace` will only replace the first
document matching the query criteria depending on a potentially given sort order.