Browse Source

Update documentation on version property handling.

Original pull request: #4553
Closes #4536
4.1.x
Christoph Strobl 2 years ago committed by Mark Paluch
parent
commit
415e4d528b
No known key found for this signature in database
GPG Key ID: 4406B84C1661DCD1
  1. 77
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java
  2. 113
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveMongoOperations.java

77
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java

@ -941,6 +941,9 @@ public interface MongoOperations extends FluentMongoOperations { @@ -941,6 +941,9 @@ public interface MongoOperations extends FluentMongoOperations {
/**
* Triggers <a href="https://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify </a>
* to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query}.
* <p>
* A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
* incremented if not explicitly specified in the update.
*
* @param query the {@link Query} class that specifies the {@link Criteria} used to find a record and also an optional
* fields specification. Must not be {@literal null}.
@ -957,6 +960,9 @@ public interface MongoOperations extends FluentMongoOperations { @@ -957,6 +960,9 @@ public interface MongoOperations extends FluentMongoOperations {
/**
* Triggers <a href="https://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify </a>
* to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query}.
* <p>
* A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
* incremented if not explicitly specified in the update.
*
* @param query the {@link Query} class that specifies the {@link Criteria} used to find a record and also an optional
* fields specification. Must not be {@literal null}.
@ -975,6 +981,9 @@ public interface MongoOperations extends FluentMongoOperations { @@ -975,6 +981,9 @@ public interface MongoOperations extends FluentMongoOperations {
* Triggers <a href="https://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify </a>
* to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query} taking
* {@link FindAndModifyOptions} into account.
* <p>
* A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
* incremented if not explicitly specified in the update.
*
* @param query the {@link Query} class that specifies the {@link Criteria} used to find a record and also an optional
* fields specification.
@ -995,6 +1004,9 @@ public interface MongoOperations extends FluentMongoOperations { @@ -995,6 +1004,9 @@ public interface MongoOperations extends FluentMongoOperations {
* Triggers <a href="https://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify </a>
* to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query} taking
* {@link FindAndModifyOptions} into account.
* <p>
* A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
* incremented if not explicitly specified in the update.
*
* @param query the {@link Query} class that specifies the {@link Criteria} used to find a record and also an optional
* fields specification. Must not be {@literal null}.
@ -1387,8 +1399,11 @@ public interface MongoOperations extends FluentMongoOperations { @@ -1387,8 +1399,11 @@ public interface MongoOperations extends FluentMongoOperations {
* leverages Type Conversion API. See
* <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation" > Spring's
* Type Conversion"</a> for more details. <br />
* Insert is used to initially store the object into the database. To update an existing object use the save method.
* <br />
* Insert is used to initially store the object into the database. To update an existing object use the
* {@link #save(Object)} method.
* <p>
* Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization.
* <p>
* The {@code objectToSave} must not be collection-like.
*
* @param objectToSave the object to store in the collection. Must not be {@literal null}.
@ -1404,7 +1419,9 @@ public interface MongoOperations extends FluentMongoOperations { @@ -1404,7 +1419,9 @@ public interface MongoOperations extends FluentMongoOperations {
* The object is converted to the MongoDB native representation using an instance of {@see MongoConverter}. Unless
* configured otherwise, an instance of {@link MappingMongoConverter} will be used. <br />
* Insert is used to initially store the object into the database. To update an existing object use the save method.
* <br />
* <p>
* Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization.
* <p>
* The {@code objectToSave} must not be collection-like.
*
* @param objectToSave the object to store in the collection. Must not be {@literal null}.
@ -1416,6 +1433,11 @@ public interface MongoOperations extends FluentMongoOperations { @@ -1416,6 +1433,11 @@ public interface MongoOperations extends FluentMongoOperations {
/**
* Insert a Collection of objects into a collection in a single batch write to the database.
* <p>
* If an object within the batch has an {@literal Id} property which holds a {@literal null} value, it will be set
* with the generated Id from MongoDB.
* <p>
* Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization.
*
* @param batchToSave the batch of objects to save. Must not be {@literal null}.
* @param entityClass class that determines the collection to use. Must not be {@literal null}.
@ -1427,6 +1449,11 @@ public interface MongoOperations extends FluentMongoOperations { @@ -1427,6 +1449,11 @@ public interface MongoOperations extends FluentMongoOperations {
/**
* Insert a batch of objects into the specified collection in a single batch write to the database.
* <p>
* If an object within the batch has an {@literal Id} property which holds a {@literal null} value, it will be set
* with the generated Id from MongoDB.
* <p>
* Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization.
*
* @param batchToSave the list of objects to save. Must not be {@literal null}.
* @param collectionName name of the collection to store the object in. Must not be {@literal null}.
@ -1437,6 +1464,11 @@ public interface MongoOperations extends FluentMongoOperations { @@ -1437,6 +1464,11 @@ public interface MongoOperations extends FluentMongoOperations {
/**
* Insert a mixed Collection of objects into a database collection determining the collection name to use based on the
* class.
* <p>
* If an object within the batch has an {@literal Id} property which holds a {@literal null} value, it will be set
* with the generated Id from MongoDB.
* <p>
* Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization.
*
* @param objectsToSave the list of objects to save. Must not be {@literal null}.
* @return the inserted objects.
@ -1454,7 +1486,11 @@ public interface MongoOperations extends FluentMongoOperations { @@ -1454,7 +1486,11 @@ public interface MongoOperations extends FluentMongoOperations {
* String then MongoDB ObjectId will be used to populate that string. Otherwise, the conversion from ObjectId to your
* property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See
* <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation" > Spring's
* Type Conversion"</a> for more details. <br />
* Type Conversion"</a> for more details.
* <p>
* A potential {@link org.springframework.data.annotation.Version} the property will be auto incremented. The
* operation raises an error in case the document has been modified in between.
* <p>
* The {@code objectToSave} must not be collection-like.
*
* @param objectToSave the object to store in the collection. Must not be {@literal null}.
@ -1462,6 +1498,8 @@ public interface MongoOperations extends FluentMongoOperations { @@ -1462,6 +1498,8 @@ public interface MongoOperations extends FluentMongoOperations {
* @throws IllegalArgumentException in case the {@code objectToSave} is collection-like.
* @throws org.springframework.data.mapping.MappingException if the target collection name cannot be
* {@link #getCollectionName(Class) derived} from the given object type.
* @throws org.springframework.dao.OptimisticLockingFailureException in case of version mismatch in case a
* {@link org.springframework.data.annotation.Version} is defined.
*/
<T> T save(T objectToSave);
@ -1474,19 +1512,29 @@ public interface MongoOperations extends FluentMongoOperations { @@ -1474,19 +1512,29 @@ public interface MongoOperations extends FluentMongoOperations {
* String then MongoDB ObjectId will be used to populate that string. Otherwise, the conversion from ObjectId to your
* property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See
* <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation">Spring's Type
* Conversion</a> for more details. <br />
* Conversion</a> for more details.
* <p>
* A potential {@link org.springframework.data.annotation.Version} the property will be auto incremented. The
* operation raises an error in case the document has been modified in between.
* <p>
* The {@code objectToSave} must not be collection-like.
*
* @param objectToSave the object to store in the collection. Must not be {@literal null}.
* @param collectionName name of the collection to store the object in. Must not be {@literal null}.
* @return the saved object.
* @throws IllegalArgumentException in case the {@code objectToSave} is collection-like.
* @throws org.springframework.dao.OptimisticLockingFailureException in case of version mismatch in case a
* {@link org.springframework.data.annotation.Version} is defined.
*/
<T> T save(T objectToSave, String collectionName);
/**
* Performs an upsert. If no document is found that matches the query, a new document is created and inserted by
* combining the query document and the update document. <br />
* combining the query document and the update document.
* <p>
* A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
* incremented if not explicitly specified in the update.
* <p>
* <strong>NOTE:</strong> {@link Query#getSortObject() sorting} is not supported by {@code db.collection.updateOne}.
* Use {@link #findAndModify(Query, UpdateDefinition, FindAndModifyOptions, Class, String)} instead.
*
@ -1528,6 +1576,9 @@ public interface MongoOperations extends FluentMongoOperations { @@ -1528,6 +1576,9 @@ public interface MongoOperations extends FluentMongoOperations {
/**
* Performs an upsert. If no document is found that matches the query, a new document is created and inserted by
* combining the query document and the update document.
* <p>
* A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
* incremented if not explicitly specified in the update.
*
* @param query the query document that specifies the criteria used to select a record to be upserted. Must not be
* {@literal null}.
@ -1545,6 +1596,9 @@ public interface MongoOperations extends FluentMongoOperations { @@ -1545,6 +1596,9 @@ public interface MongoOperations extends FluentMongoOperations {
/**
* Updates the first object that is found in the collection of the entity class that matches the query document with
* the provided update document.
* <p>
* A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
* incremented if not explicitly specified in the update.
*
* @param query the query document that specifies the criteria used to select a record to be updated. Must not be
* {@literal null}.
@ -1583,7 +1637,10 @@ public interface MongoOperations extends FluentMongoOperations { @@ -1583,7 +1637,10 @@ public interface MongoOperations extends FluentMongoOperations {
/**
* Updates the first object that is found in the specified collection that matches the query document criteria with
* the provided updated document. <br />
* the provided updated document.
* <p>
* A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
* incremented if not explicitly specified in the update.
*
* @param query the query document that specifies the criteria used to select a record to be updated. Must not be
* {@literal null}.
@ -1601,6 +1658,9 @@ public interface MongoOperations extends FluentMongoOperations { @@ -1601,6 +1658,9 @@ public interface MongoOperations extends FluentMongoOperations {
/**
* Updates all objects that are found in the collection for the entity class that matches the query document criteria
* with the provided updated document.
* <p>
* A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
* incremented if not explicitly specified in the update.
*
* @param query the query document that specifies the criteria used to select a record to be updated. Must not be
* {@literal null}.
@ -1638,6 +1698,9 @@ public interface MongoOperations extends FluentMongoOperations { @@ -1638,6 +1698,9 @@ public interface MongoOperations extends FluentMongoOperations {
/**
* Updates all objects that are found in the collection for the entity class that matches the query document criteria
* with the provided updated document.
* <p>
* A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
* incremented if not explicitly specified in the update.
*
* @param query the query document that specifies the criteria used to select a record to be updated. Must not be
* {@literal null}.

113
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveMongoOperations.java

@ -757,6 +757,9 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -757,6 +757,9 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
/**
* Triggers <a href="https://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify</a>
* to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query}.
* <p>
*A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
*incremented if not explicitly specified in the update.
*
* @param query the {@link Query} class that specifies the {@link Criteria} used to find a record and also an optional
* fields specification. Must not be {@literal null}.
@ -772,6 +775,9 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -772,6 +775,9 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
/**
* Triggers <a href="https://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify</a>
* to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query}.
* <p>
* A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
* incremented if not explicitly specified in the update.
*
* @param query the {@link Query} class that specifies the {@link Criteria} used to find a record and also an optional
* fields specification. Must not be {@literal null}.
@ -789,6 +795,9 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -789,6 +795,9 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
* Triggers <a href="https://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify</a>
* to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query} taking
* {@link FindAndModifyOptions} into account.
* <p>
* A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
* incremented if not explicitly specified in the update.
*
* @param query the {@link Query} class that specifies the {@link Criteria} used to find a record and also an optional
* fields specification.
@ -807,6 +816,9 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -807,6 +816,9 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
* Triggers <a href="https://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify</a>
* to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query} taking
* {@link FindAndModifyOptions} into account.
* <p>
* A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
* incremented if not explicitly specified in the update.
*
* @param query the {@link Query} class that specifies the {@link Criteria} used to find a record and also an optional
* fields specification. Must not be {@literal null}.
@ -1189,7 +1201,9 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -1189,7 +1201,9 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
* <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation" > Spring's
* Type Conversion"</a> for more details. <br />
* Insert is used to initially store the object into the database. To update an existing object use the save method.
* <br />
* <p>
* Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization.
* <p>
* The {@code objectToSave} must not be collection-like.
*
* @param objectToSave the object to store in the collection. Must not be {@literal null}.
@ -1205,7 +1219,9 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -1205,7 +1219,9 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
* The object is converted to the MongoDB native representation using an instance of {@see MongoConverter}. Unless
* configured otherwise, an instance of {@link MappingMongoConverter} will be used. <br />
* Insert is used to initially store the object into the database. To update an existing object use the save method.
* <br />
* <p>
* Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization.
* <p>
* The {@code objectToSave} must not be collection-like.
*
* @param objectToSave the object to store in the collection. Must not be {@literal null}.
@ -1217,6 +1233,11 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -1217,6 +1233,11 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
/**
* Insert a Collection of objects into a collection in a single batch write to the database.
* <p>
* If an object within the batch has an {@literal Id} property which holds a {@literal null} value, it will be set
* with the generated Id from MongoDB.
* <p>
* Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization.
*
* @param batchToSave the batch of objects to save. Must not be {@literal null}.
* @param entityClass class that determines the collection to use. Must not be {@literal null}.
@ -1228,6 +1249,11 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -1228,6 +1249,11 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
/**
* Insert a batch of objects into the specified collection in a single batch write to the database.
* <p>
* If an object within the batch has an {@literal Id} property which holds a {@literal null} value, it will be set
* with the generated Id from MongoDB.
* <p>
* Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization.
*
* @param batchToSave the list of objects to save. Must not be {@literal null}.
* @param collectionName name of the collection to store the object in. Must not be {@literal null}.
@ -1238,6 +1264,11 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -1238,6 +1264,11 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
/**
* Insert a mixed Collection of objects into a database collection determining the collection name to use based on the
* class.
* <p>
* If an object within the batch has an {@literal Id} property which holds a {@literal null} value, it will be set
* with the generated Id from MongoDB.
* <p>
* Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization.
*
* @param objectsToSave the list of objects to save. Must not be {@literal null}.
* @return the saved objects.
@ -1255,7 +1286,9 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -1255,7 +1286,9 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
* <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation" > Spring's
* Type Conversion"</a> for more details. <br />
* Insert is used to initially store the object into the database. To update an existing object use the save method.
*
* <p>
* A potential {@link org.springframework.data.annotation.Version} the property will be auto incremented. The
* operation raises an error in case the document has been modified in between.
* @param objectToSave the object to store in the collection. Must not be {@literal null}.
* @return the inserted objects.
*/
@ -1263,6 +1296,11 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -1263,6 +1296,11 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
/**
* Insert a Collection of objects into a collection in a single batch write to the database.
* <p>
* If an object within the batch has an {@literal Id} property which holds a {@literal null} value, it will be set
* with the generated Id from MongoDB.
* <p>
* Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization.
*
* @param batchToSave the publisher which provides objects to save. Must not be {@literal null}.
* @param entityClass class that determines the collection to use. Must not be {@literal null}.
@ -1274,6 +1312,11 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -1274,6 +1312,11 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
/**
* Insert objects into the specified collection in a single batch write to the database.
* <p>
* If an object within the batch has an {@literal Id} property which holds a {@literal null} value, it will be set
* with the generated Id from MongoDB.
* <p>
* Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization.
*
* @param batchToSave the publisher which provides objects to save. Must not be {@literal null}.
* @param collectionName name of the collection to store the object in. Must not be {@literal null}.
@ -1284,6 +1327,11 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -1284,6 +1327,11 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
/**
* Insert a mixed Collection of objects into a database collection determining the collection name to use based on the
* class.
* <p>
* If an object within the batch has an {@literal Id} property which holds a {@literal null} value, it will be set
* with the generated Id from MongoDB.
* <p>
* Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization.
*
* @param objectsToSave the publisher which provides objects to save. Must not be {@literal null}.
* @return the inserted objects.
@ -1299,7 +1347,11 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -1299,7 +1347,11 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
* String then MongoDB ObjectId will be used to populate that string. Otherwise, the conversion from ObjectId to your
* property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See
* <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation" > Spring's
* Type Conversion"</a> for more details. <br />
* Type Conversion"</a> for more details.
* <p>
* A potential {@link org.springframework.data.annotation.Version} the property will be auto incremented. The
* operation raises an error in case the document has been modified in between.
* <p>
* The {@code objectToSave} must not be collection-like.
*
* @param objectToSave the object to store in the collection. Must not be {@literal null}.
@ -1307,6 +1359,8 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -1307,6 +1359,8 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
* @throws IllegalArgumentException in case the {@code objectToSave} is collection-like.
* @throws org.springframework.data.mapping.MappingException if the target collection name cannot be
* {@link #getCollectionName(Class) derived} from the given object type.
* @throws org.springframework.dao.OptimisticLockingFailureException in case of version mismatch in case a
* {@link org.springframework.data.annotation.Version} is defined.
*/
<T> Mono<T> save(T objectToSave);
@ -1320,11 +1374,16 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -1320,11 +1374,16 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
* property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See
* <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation">Spring's Type
* Conversion</a> for more details.
* <p>
* A potential {@link org.springframework.data.annotation.Version} the property will be auto incremented. The
* operation raises an error in case the document has been modified in between.
*
* @param objectToSave the object to store in the collection. Must not be {@literal null}.
* @param collectionName name of the collection to store the object in. Must not be {@literal null}.
* @return the saved object.
* @throws IllegalArgumentException in case the {@code objectToSave} is collection-like.
* @throws org.springframework.dao.OptimisticLockingFailureException in case of version mismatch in case a
* {@link org.springframework.data.annotation.Version} is defined.
*/
<T> Mono<T> save(T objectToSave, String collectionName);
@ -1338,11 +1397,16 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -1338,11 +1397,16 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
* property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See
* <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation"> Spring's Type
* Conversion</a> for more details.
* <p>
* A potential {@link org.springframework.data.annotation.Version} the property will be auto incremented. The
* operation raises an error in case the document has been modified in between.
*
* @param objectToSave the object to store in the collection. Must not be {@literal null}.
* @return the saved object.
* @throws org.springframework.data.mapping.MappingException if the target collection name cannot be
* {@link #getCollectionName(Class) derived} from the given object type.
* @throws org.springframework.dao.OptimisticLockingFailureException in case of version mismatch in case a
* {@link org.springframework.data.annotation.Version} is defined.
*/
<T> Mono<T> save(Mono<? extends T> objectToSave);
@ -1356,16 +1420,25 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -1356,16 +1420,25 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
* property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See
* <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation">Spring's Type
* Conversion</a> for more details.
* <p>
* A potential {@link org.springframework.data.annotation.Version} the property will be auto incremented. The
* operation raises an error in case the document has been modified in between.
*
* @param objectToSave the object to store in the collReactiveMongoOperationsection. Must not be {@literal null}.
* @param collectionName name of the collection to store the object in. Must not be {@literal null}.
* @return the saved object.
* @throws org.springframework.dao.OptimisticLockingFailureException in case of version mismatch in case a
* {@link org.springframework.data.annotation.Version} is defined.
*/
<T> Mono<T> save(Mono<? extends T> objectToSave, String collectionName);
/**
* Performs an upsert. If no document is found that matches the query, a new document is created and inserted by
* combining the query document and the update document. <br />
* combining the query document and the update document.
* <p>
* A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
* incremented if not explicitly specified in the update.
* <p>
* <strong>NOTE:</strong> {@link Query#getSortObject() sorting} is not supported by {@code db.collection.updateOne}.
* Use {@link #findAndModify(Query, UpdateDefinition, Class)} instead.
*
@ -1405,6 +1478,9 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -1405,6 +1478,9 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
/**
* Performs an upsert. If no document is found that matches the query, a new document is created and inserted by
* combining the query document and the update document.
* <p>
* A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
* incremented if not explicitly specified in the update.
*
* @param query the query document that specifies the criteria used to select a record to be upserted. Must not be
* {@literal null}.
@ -1421,7 +1497,11 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -1421,7 +1497,11 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
/**
* Updates the first object that is found in the collection of the entity class that matches the query document with
* the provided update document. <br />
* the provided update document.
* <p>
* A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
* incremented if not explicitly specified in the update.
*
* <strong>NOTE:</strong> {@link Query#getSortObject() sorting} is not supported by {@code db.collection.updateOne}.
* Use {@link #findAndModify(Query, UpdateDefinition, Class)} instead.
*
@ -1462,7 +1542,10 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -1462,7 +1542,10 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
/**
* Updates the first object that is found in the specified collection that matches the query document criteria with
* the provided updated document. <br />
* the provided updated document.
* <p>
* A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
* incremented if not explicitly specified in the update.
*
* @param query the query document that specifies the criteria used to select a record to be updated. Must not be
* {@literal null}.
@ -1480,6 +1563,9 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -1480,6 +1563,9 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
/**
* Updates all objects that are found in the collection for the entity class that matches the query document criteria
* with the provided updated document.
* <p>
* A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
* incremented if not explicitly specified in the update.
*
* @param query the query document that specifies the criteria used to select a record to be updated. Must not be
* {@literal null}.
@ -1517,6 +1603,9 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -1517,6 +1603,9 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
/**
* Updates all objects that are found in the collection for the entity class that matches the query document criteria
* with the provided updated document.
* <p>
* A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
* incremented if not explicitly specified in the update.
*
* @param query the query document that specifies the criteria used to select a record to be updated. Must not be
* {@literal null}.
@ -1532,7 +1621,8 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -1532,7 +1621,8 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
Mono<UpdateResult> updateMulti(Query query, UpdateDefinition update, Class<?> entityClass, String collectionName);
/**
* Remove the given object from the collection by id.
* Remove the given object from the collection by {@literal id} and (if applicable) its
* {@link org.springframework.data.annotation.Version}.
*
* @param object must not be {@literal null}.
* @return the {@link DeleteResult} which lets you access the results of the previous delete.
@ -1551,7 +1641,8 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -1551,7 +1641,8 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
Mono<DeleteResult> remove(Object object, String collectionName);
/**
* Remove the given object from the collection by id.
* Remove the given object from the collection by {@literal id} and (if applicable) its
* {@link org.springframework.data.annotation.Version}.
*
* @param objectToRemove must not be {@literal null}.
* @return the {@link DeleteResult} which lets you access the results of the previous delete.
@ -1561,7 +1652,8 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -1561,7 +1652,8 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
Mono<DeleteResult> remove(Mono<? extends Object> objectToRemove);
/**
* Removes the given object from the given collection.
* Removes the given object from the given collection by {@literal id} and (if applicable) its
* {@link org.springframework.data.annotation.Version}.
*
* @param objectToRemove must not be {@literal null}.
* @param collectionName name of the collection where the objects will removed, must not be {@literal null} or empty.
@ -1782,7 +1874,6 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { @@ -1782,7 +1874,6 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
<T> Flux<T> mapReduce(Query filterQuery, Class<?> domainType, String inputCollectionName, Class<T> resultType,
String mapFunction, String reduceFunction, MapReduceOptions options);
/**
* Returns the underlying {@link MongoConverter}.
*

Loading…
Cancel
Save