diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java index 2f3c0dd92..314e8e5e0 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java @@ -941,6 +941,9 @@ public interface MongoOperations extends FluentMongoOperations { /** * Triggers findAndModify * to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query}. + *
+ * 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 { /** * Triggers findAndModify * to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query}. + *
+ * 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 { * Triggers findAndModify * to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query} taking * {@link FindAndModifyOptions} into account. + *
+ * 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 { * Triggers findAndModify * to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query} taking * {@link FindAndModifyOptions} into account. + *
+ * 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 {
* leverages Type Conversion API. See
* Spring's
* Type Conversion" for more details.
- * Insert is used to initially store the object into the database. To update an existing object use the save method.
- *
+ * Insert is used to initially store the object into the database. To update an existing object use the
+ * {@link #save(Object)} method.
+ *
+ * Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization. + *
* 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 {
* 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.
* Insert is used to initially store the object into the database. To update an existing object use the save method.
- *
+ *
+ * Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization. + *
* 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 { /** * Insert a Collection of objects into a collection in a single batch write to the database. + *
+ * 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. + *
+ * 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 { /** * Insert a batch of objects into the specified collection in a single batch write to the database. + *
+ * 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. + *
+ * 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 { /** * Insert a mixed Collection of objects into a database collection determining the collection name to use based on the * class. + *
+ * 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. + *
+ * 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 {
* 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
* Spring's
- * Type Conversion" for more details.
+ * Type Conversion" for more details.
+ *
+ * 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. + *
* 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 {
* @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.
*/
+ * 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.
+ *
* 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.
*/
+ * A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
+ * incremented if not explicitly specified in the update.
+ *
* NOTE: {@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 {
/**
* 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.
+ *
+ * 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 {
/**
* Updates the first object that is found in the collection of the entity class that matches the query document with
* the provided update document.
+ *
+ * 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 {
/**
* Updates the first object that is found in the specified collection that matches the query document criteria with
- * the provided updated document.
+ * 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 {
/**
* Updates all objects that are found in the collection for the entity class that matches the query document criteria
* with the provided updated document.
+ *
+ * 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 {
/**
* Updates all objects that are found in the collection for the entity class that matches the query document criteria
* with the provided updated document.
+ *
+ * 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}.
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveMongoOperations.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveMongoOperations.java
index 9f391bb79..84397c377 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveMongoOperations.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveMongoOperations.java
@@ -757,6 +757,9 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
/**
* Triggers findAndModify
* to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query}.
+ *
+ *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 {
/**
* Triggers findAndModify
* to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query}.
+ *
+ * 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 {
* Triggers findAndModify
* to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query} taking
* {@link FindAndModifyOptions} into account.
+ *
+ * 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 {
* Triggers findAndModify
* to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query} taking
* {@link FindAndModifyOptions} into account.
+ *
+ * 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 {
* Spring's
* Type Conversion" for more details.
+ * Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization.
+ *
* 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 {
* 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.
+ * Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization.
+ *
* 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 {
/**
* Insert a Collection of objects into a collection in a single batch write to the database.
+ *
+ * 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.
+ *
+ * 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 {
/**
* Insert a batch of objects into the specified collection in a single batch write to the database.
+ *
+ * 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.
+ *
+ * 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 {
/**
* Insert a mixed Collection of objects into a database collection determining the collection name to use based on the
* class.
+ *
+ * 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.
+ *
+ * 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 {
* Spring's
* Type Conversion" for more details.
+ * 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 {
/**
* Insert a Collection of objects into a collection in a single batch write to the database.
+ *
+ * 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.
+ *
+ * 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 {
/**
* Insert objects into the specified collection in a single batch write to the database.
+ *
+ * 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.
+ *
+ * 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 {
/**
* Insert a mixed Collection of objects into a database collection determining the collection name to use based on the
* class.
+ *
+ * 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.
+ *
+ * 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 {
* 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
* Spring's
- * Type Conversion" for more details.
+ * 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.
+ *
* 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 {
* @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.
*/
+ * 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.
*/
+ * 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.
*/
+ * 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.
*/
+ * A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
+ * incremented if not explicitly specified in the update.
+ *
* NOTE: {@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 {
/**
* 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.
+ *
+ * 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 {
/**
* Updates the first object that is found in the collection of the entity class that matches the query document with
- * the provided update document.
+ * A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
+ * incremented if not explicitly specified in the update.
+ *
* NOTE: {@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 {
/**
* Updates the first object that is found in the specified collection that matches the query document criteria with
- * the provided updated document.
+ * 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 {
/**
* Updates all objects that are found in the collection for the entity class that matches the query document criteria
* with the provided updated document.
+ *
+ * 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 {
/**
* Updates all objects that are found in the collection for the entity class that matches the query document criteria
* with the provided updated document.
+ *
+ * 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 {
Mono
+ * Conversion for more details.
+ *
+ * combining the query document and the update document.
+ *
+ * the provided updated document.
+ *
* Insert is used to initially store the object into the database. To update an existing object use the save method.
- *
+ *
* Insert is used to initially store the object into the database. To update an existing object use the save method.
- *
+ *
* Insert is used to initially store the object into the database. To update an existing object use the save method.
- *
+ *
+ * Type Conversion" for more details.
+ *
+ * combining the query document and the update document.
+ *
+ * the provided update document.
+ *
+ * the provided updated document.
+ *