@@ -941,6 +941,9 @@ default <T> List<T> findDistinct(Query query, String field, String collection, C
941941 /**
942942 * Triggers <a href="https://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify </a>
943943 * to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query}.
944+ * <p>
945+ * A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
946+ * incremented if not explicitly specified in the update.
944947 *
945948 * @param query the {@link Query} class that specifies the {@link Criteria} used to find a record and also an optional
946949 * fields specification. Must not be {@literal null}.
@@ -957,6 +960,9 @@ default <T> List<T> findDistinct(Query query, String field, String collection, C
957960 /**
958961 * Triggers <a href="https://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify </a>
959962 * to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query}.
963+ * <p>
964+ * A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
965+ * incremented if not explicitly specified in the update.
960966 *
961967 * @param query the {@link Query} class that specifies the {@link Criteria} used to find a record and also an optional
962968 * fields specification. Must not be {@literal null}.
@@ -975,6 +981,9 @@ default <T> List<T> findDistinct(Query query, String field, String collection, C
975981 * Triggers <a href="https://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify </a>
976982 * to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query} taking
977983 * {@link FindAndModifyOptions} into account.
984+ * <p>
985+ * A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
986+ * incremented if not explicitly specified in the update.
978987 *
979988 * @param query the {@link Query} class that specifies the {@link Criteria} used to find a record and also an optional
980989 * fields specification.
@@ -995,6 +1004,9 @@ default <T> List<T> findDistinct(Query query, String field, String collection, C
9951004 * Triggers <a href="https://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify </a>
9961005 * to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query} taking
9971006 * {@link FindAndModifyOptions} into account.
1007+ * <p>
1008+ * A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
1009+ * incremented if not explicitly specified in the update.
9981010 *
9991011 * @param query the {@link Query} class that specifies the {@link Criteria} used to find a record and also an optional
10001012 * fields specification. Must not be {@literal null}.
@@ -1387,8 +1399,11 @@ default long exactCount(Query query, String collectionName) {
13871399 * leverages Type Conversion API. See
13881400 * <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation" > Spring's
13891401 * Type Conversion"</a> for more details. <br />
1390- * Insert is used to initially store the object into the database. To update an existing object use the save method.
1391- * <br />
1402+ * Insert is used to initially store the object into the database. To update an existing object use the
1403+ * {@link #save(Object)} method.
1404+ * <p>
1405+ * Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization.
1406+ * <p>
13921407 * The {@code objectToSave} must not be collection-like.
13931408 *
13941409 * @param objectToSave the object to store in the collection. Must not be {@literal null}.
@@ -1404,7 +1419,9 @@ default long exactCount(Query query, String collectionName) {
14041419 * The object is converted to the MongoDB native representation using an instance of {@see MongoConverter}. Unless
14051420 * configured otherwise, an instance of {@link MappingMongoConverter} will be used. <br />
14061421 * Insert is used to initially store the object into the database. To update an existing object use the save method.
1407- * <br />
1422+ * <p>
1423+ * Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization.
1424+ * <p>
14081425 * The {@code objectToSave} must not be collection-like.
14091426 *
14101427 * @param objectToSave the object to store in the collection. Must not be {@literal null}.
@@ -1416,6 +1433,11 @@ default long exactCount(Query query, String collectionName) {
14161433
14171434 /**
14181435 * Insert a Collection of objects into a collection in a single batch write to the database.
1436+ * <p>
1437+ * If an object within the batch has an {@literal Id} property which holds a {@literal null} value, it will be set
1438+ * with the generated Id from MongoDB.
1439+ * <p>
1440+ * Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization.
14191441 *
14201442 * @param batchToSave the batch of objects to save. Must not be {@literal null}.
14211443 * @param entityClass class that determines the collection to use. Must not be {@literal null}.
@@ -1427,6 +1449,11 @@ default long exactCount(Query query, String collectionName) {
14271449
14281450 /**
14291451 * Insert a batch of objects into the specified collection in a single batch write to the database.
1452+ * <p>
1453+ * If an object within the batch has an {@literal Id} property which holds a {@literal null} value, it will be set
1454+ * with the generated Id from MongoDB.
1455+ * <p>
1456+ * Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization.
14301457 *
14311458 * @param batchToSave the list of objects to save. Must not be {@literal null}.
14321459 * @param collectionName name of the collection to store the object in. Must not be {@literal null}.
@@ -1437,6 +1464,11 @@ default long exactCount(Query query, String collectionName) {
14371464 /**
14381465 * Insert a mixed Collection of objects into a database collection determining the collection name to use based on the
14391466 * class.
1467+ * <p>
1468+ * If an object within the batch has an {@literal Id} property which holds a {@literal null} value, it will be set
1469+ * with the generated Id from MongoDB.
1470+ * <p>
1471+ * Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization.
14401472 *
14411473 * @param objectsToSave the list of objects to save. Must not be {@literal null}.
14421474 * @return the inserted objects.
@@ -1454,14 +1486,20 @@ default long exactCount(Query query, String collectionName) {
14541486 * String then MongoDB ObjectId will be used to populate that string. Otherwise, the conversion from ObjectId to your
14551487 * property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See
14561488 * <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation" > Spring's
1457- * Type Conversion"</a> for more details. <br />
1489+ * Type Conversion"</a> for more details.
1490+ * <p>
1491+ * A potential {@link org.springframework.data.annotation.Version} the property will be auto incremented. The
1492+ * operation raises an error in case the document has been modified in between.
1493+ * <p>
14581494 * The {@code objectToSave} must not be collection-like.
14591495 *
14601496 * @param objectToSave the object to store in the collection. Must not be {@literal null}.
14611497 * @return the saved object.
14621498 * @throws IllegalArgumentException in case the {@code objectToSave} is collection-like.
14631499 * @throws org.springframework.data.mapping.MappingException if the target collection name cannot be
14641500 * {@link #getCollectionName(Class) derived} from the given object type.
1501+ * @throws org.springframework.dao.OptimisticLockingFailureException in case of version mismatch in case a
1502+ * {@link org.springframework.data.annotation.Version} is defined.
14651503 */
14661504 <T > T save (T objectToSave );
14671505
@@ -1474,19 +1512,29 @@ default long exactCount(Query query, String collectionName) {
14741512 * String then MongoDB ObjectId will be used to populate that string. Otherwise, the conversion from ObjectId to your
14751513 * property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See
14761514 * <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation">Spring's Type
1477- * Conversion</a> for more details. <br />
1515+ * Conversion</a> for more details.
1516+ * <p>
1517+ * A potential {@link org.springframework.data.annotation.Version} the property will be auto incremented. The
1518+ * operation raises an error in case the document has been modified in between.
1519+ * <p>
14781520 * The {@code objectToSave} must not be collection-like.
14791521 *
14801522 * @param objectToSave the object to store in the collection. Must not be {@literal null}.
14811523 * @param collectionName name of the collection to store the object in. Must not be {@literal null}.
14821524 * @return the saved object.
14831525 * @throws IllegalArgumentException in case the {@code objectToSave} is collection-like.
1526+ * @throws org.springframework.dao.OptimisticLockingFailureException in case of version mismatch in case a
1527+ * {@link org.springframework.data.annotation.Version} is defined.
14841528 */
14851529 <T > T save (T objectToSave , String collectionName );
14861530
14871531 /**
14881532 * Performs an upsert. If no document is found that matches the query, a new document is created and inserted by
1489- * combining the query document and the update document. <br />
1533+ * combining the query document and the update document.
1534+ * <p>
1535+ * A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
1536+ * incremented if not explicitly specified in the update.
1537+ * <p>
14901538 * <strong>NOTE:</strong> {@link Query#getSortObject() sorting} is not supported by {@code db.collection.updateOne}.
14911539 * Use {@link #findAndModify(Query, UpdateDefinition, FindAndModifyOptions, Class, String)} instead.
14921540 *
@@ -1528,6 +1576,9 @@ default long exactCount(Query query, String collectionName) {
15281576 /**
15291577 * Performs an upsert. If no document is found that matches the query, a new document is created and inserted by
15301578 * combining the query document and the update document.
1579+ * <p>
1580+ * A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
1581+ * incremented if not explicitly specified in the update.
15311582 *
15321583 * @param query the query document that specifies the criteria used to select a record to be upserted. Must not be
15331584 * {@literal null}.
@@ -1545,6 +1596,9 @@ default long exactCount(Query query, String collectionName) {
15451596 /**
15461597 * Updates the first object that is found in the collection of the entity class that matches the query document with
15471598 * the provided update document.
1599+ * <p>
1600+ * A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
1601+ * incremented if not explicitly specified in the update.
15481602 *
15491603 * @param query the query document that specifies the criteria used to select a record to be updated. Must not be
15501604 * {@literal null}.
@@ -1583,7 +1637,10 @@ default long exactCount(Query query, String collectionName) {
15831637
15841638 /**
15851639 * Updates the first object that is found in the specified collection that matches the query document criteria with
1586- * the provided updated document. <br />
1640+ * the provided updated document.
1641+ * <p>
1642+ * A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
1643+ * incremented if not explicitly specified in the update.
15871644 *
15881645 * @param query the query document that specifies the criteria used to select a record to be updated. Must not be
15891646 * {@literal null}.
@@ -1601,6 +1658,9 @@ default long exactCount(Query query, String collectionName) {
16011658 /**
16021659 * Updates all objects that are found in the collection for the entity class that matches the query document criteria
16031660 * with the provided updated document.
1661+ * <p>
1662+ * A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
1663+ * incremented if not explicitly specified in the update.
16041664 *
16051665 * @param query the query document that specifies the criteria used to select a record to be updated. Must not be
16061666 * {@literal null}.
@@ -1638,6 +1698,9 @@ default long exactCount(Query query, String collectionName) {
16381698 /**
16391699 * Updates all objects that are found in the collection for the entity class that matches the query document criteria
16401700 * with the provided updated document.
1701+ * <p>
1702+ * A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
1703+ * incremented if not explicitly specified in the update.
16411704 *
16421705 * @param query the query document that specifies the criteria used to select a record to be updated. Must not be
16431706 * {@literal null}.
0 commit comments