@@ -945,6 +945,9 @@ default <T> List<T> findDistinct(Query query, String field, String collection, C
945
945
/**
946
946
* Triggers <a href="https://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify </a>
947
947
* to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query}.
948
+ * <p>
949
+ * A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
950
+ * incremented if not explicitly specified in the update.
948
951
*
949
952
* @param query the {@link Query} class that specifies the {@link Criteria} used to find a document and also an
950
953
* optional fields specification. Must not be {@literal null}.
@@ -961,6 +964,9 @@ default <T> List<T> findDistinct(Query query, String field, String collection, C
961
964
/**
962
965
* Triggers <a href="https://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify </a>
963
966
* to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query}.
967
+ * <p>
968
+ * A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
969
+ * incremented if not explicitly specified in the update.
964
970
*
965
971
* @param query the {@link Query} class that specifies the {@link Criteria} used to find a document and also an
966
972
* optional fields specification. Must not be {@literal null}.
@@ -979,6 +985,9 @@ default <T> List<T> findDistinct(Query query, String field, String collection, C
979
985
* Triggers <a href="https://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify </a>
980
986
* to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query} taking
981
987
* {@link FindAndModifyOptions} into account.
988
+ * <p>
989
+ * A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
990
+ * incremented if not explicitly specified in the update.
982
991
*
983
992
* @param query the {@link Query} class that specifies the {@link Criteria} used to find a document and also an
984
993
* optional fields specification.
@@ -999,6 +1008,9 @@ default <T> List<T> findDistinct(Query query, String field, String collection, C
999
1008
* Triggers <a href="https://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify </a>
1000
1009
* to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query} taking
1001
1010
* {@link FindAndModifyOptions} into account.
1011
+ * <p>
1012
+ * A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
1013
+ * incremented if not explicitly specified in the update.
1002
1014
*
1003
1015
* @param query the {@link Query} class that specifies the {@link Criteria} used to find a document and also an
1004
1016
* optional fields specification. Must not be {@literal null}.
@@ -1391,8 +1403,11 @@ default long exactCount(Query query, String collectionName) {
1391
1403
* leverages Type Conversion API. See
1392
1404
* <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation" > Spring's
1393
1405
* Type Conversion"</a> for more details. <br />
1394
- * Insert is used to initially store the object into the database. To update an existing object use the save method.
1395
- * <br />
1406
+ * Insert is used to initially store the object into the database. To update an existing object use the
1407
+ * {@link #save(Object)} method.
1408
+ * <p>
1409
+ * Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization.
1410
+ * <p>
1396
1411
* The {@code objectToSave} must not be collection-like.
1397
1412
*
1398
1413
* @param objectToSave the object to store in the collection. Must not be {@literal null}.
@@ -1408,7 +1423,9 @@ default long exactCount(Query query, String collectionName) {
1408
1423
* The object is converted to the MongoDB native representation using an instance of {@see MongoConverter}. Unless
1409
1424
* configured otherwise, an instance of {@link MappingMongoConverter} will be used. <br />
1410
1425
* Insert is used to initially store the object into the database. To update an existing object use the save method.
1411
- * <br />
1426
+ * <p>
1427
+ * Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization.
1428
+ * <p>
1412
1429
* The {@code objectToSave} must not be collection-like.
1413
1430
*
1414
1431
* @param objectToSave the object to store in the collection. Must not be {@literal null}.
@@ -1420,6 +1437,11 @@ default long exactCount(Query query, String collectionName) {
1420
1437
1421
1438
/**
1422
1439
* Insert a Collection of objects into a collection in a single batch write to the database.
1440
+ * <p>
1441
+ * If an object within the batch has an {@literal Id} property which holds a {@literal null} value, it will be set
1442
+ * with the generated Id from MongoDB.
1443
+ * <p>
1444
+ * Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization.
1423
1445
*
1424
1446
* @param batchToSave the batch of objects to save. Must not be {@literal null}.
1425
1447
* @param entityClass class that determines the collection to use. Must not be {@literal null}.
@@ -1431,6 +1453,11 @@ default long exactCount(Query query, String collectionName) {
1431
1453
1432
1454
/**
1433
1455
* Insert a batch of objects into the specified collection in a single batch write to the database.
1456
+ * <p>
1457
+ * If an object within the batch has an {@literal Id} property which holds a {@literal null} value, it will be set
1458
+ * with the generated Id from MongoDB.
1459
+ * <p>
1460
+ * Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization.
1434
1461
*
1435
1462
* @param batchToSave the list of objects to save. Must not be {@literal null}.
1436
1463
* @param collectionName name of the collection to store the object in. Must not be {@literal null}.
@@ -1441,6 +1468,11 @@ default long exactCount(Query query, String collectionName) {
1441
1468
/**
1442
1469
* Insert a mixed Collection of objects into a database collection determining the collection name to use based on the
1443
1470
* class.
1471
+ * <p>
1472
+ * If an object within the batch has an {@literal Id} property which holds a {@literal null} value, it will be set
1473
+ * with the generated Id from MongoDB.
1474
+ * <p>
1475
+ * Inserting new objects will trigger {@link org.springframework.data.annotation.Version} property initialization.
1444
1476
*
1445
1477
* @param objectsToSave the list of objects to save. Must not be {@literal null}.
1446
1478
* @return the inserted objects.
@@ -1458,14 +1490,20 @@ default long exactCount(Query query, String collectionName) {
1458
1490
* String then MongoDB ObjectId will be used to populate that string. Otherwise, the conversion from ObjectId to your
1459
1491
* property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See
1460
1492
* <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation" > Spring's
1461
- * Type Conversion"</a> for more details. <br />
1493
+ * Type Conversion"</a> for more details.
1494
+ * <p>
1495
+ * A potential {@link org.springframework.data.annotation.Version} the property will be auto incremented. The
1496
+ * operation raises an error in case the document has been modified in between.
1497
+ * <p>
1462
1498
* The {@code objectToSave} must not be collection-like.
1463
1499
*
1464
1500
* @param objectToSave the object to store in the collection. Must not be {@literal null}.
1465
1501
* @return the saved object.
1466
1502
* @throws IllegalArgumentException in case the {@code objectToSave} is collection-like.
1467
1503
* @throws org.springframework.data.mapping.MappingException if the target collection name cannot be
1468
1504
* {@link #getCollectionName(Class) derived} from the given object type.
1505
+ * @throws org.springframework.dao.OptimisticLockingFailureException in case of version mismatch in case a
1506
+ * {@link org.springframework.data.annotation.Version} is defined.
1469
1507
*/
1470
1508
<T > T save (T objectToSave );
1471
1509
@@ -1478,19 +1516,29 @@ default long exactCount(Query query, String collectionName) {
1478
1516
* String then MongoDB ObjectId will be used to populate that string. Otherwise, the conversion from ObjectId to your
1479
1517
* property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See
1480
1518
* <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation">Spring's Type
1481
- * Conversion</a> for more details. <br />
1519
+ * Conversion</a> for more details.
1520
+ * <p>
1521
+ * A potential {@link org.springframework.data.annotation.Version} the property will be auto incremented. The
1522
+ * operation raises an error in case the document has been modified in between.
1523
+ * <p>
1482
1524
* The {@code objectToSave} must not be collection-like.
1483
1525
*
1484
1526
* @param objectToSave the object to store in the collection. Must not be {@literal null}.
1485
1527
* @param collectionName name of the collection to store the object in. Must not be {@literal null}.
1486
1528
* @return the saved object.
1487
1529
* @throws IllegalArgumentException in case the {@code objectToSave} is collection-like.
1530
+ * @throws org.springframework.dao.OptimisticLockingFailureException in case of version mismatch in case a
1531
+ * {@link org.springframework.data.annotation.Version} is defined.
1488
1532
*/
1489
1533
<T > T save (T objectToSave , String collectionName );
1490
1534
1491
1535
/**
1492
1536
* Performs an upsert. If no document is found that matches the query, a new document is created and inserted by
1493
- * combining the query document and the update document. <br />
1537
+ * combining the query document and the update document.
1538
+ * <p>
1539
+ * A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
1540
+ * incremented if not explicitly specified in the update.
1541
+ * <p>
1494
1542
* <strong>NOTE:</strong> {@link Query#getSortObject() sorting} is not supported by {@code db.collection.updateOne}.
1495
1543
* Use {@link #findAndModify(Query, UpdateDefinition, FindAndModifyOptions, Class, String)} instead.
1496
1544
*
@@ -1532,6 +1580,9 @@ default long exactCount(Query query, String collectionName) {
1532
1580
/**
1533
1581
* Performs an upsert. If no document is found that matches the query, a new document is created and inserted by
1534
1582
* combining the query document and the update document.
1583
+ * <p>
1584
+ * A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
1585
+ * incremented if not explicitly specified in the update.
1535
1586
*
1536
1587
* @param query the query document that specifies the criteria used to select a document to be upserted. Must not be
1537
1588
* {@literal null}.
@@ -1549,6 +1600,9 @@ default long exactCount(Query query, String collectionName) {
1549
1600
/**
1550
1601
* Updates the first object that is found in the collection of the entity class that matches the query document with
1551
1602
* the provided update document.
1603
+ * <p>
1604
+ * A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
1605
+ * incremented if not explicitly specified in the update.
1552
1606
*
1553
1607
* @param query the query document that specifies the criteria used to select a document to be updated. Must not be
1554
1608
* {@literal null}.
@@ -1587,7 +1641,10 @@ default long exactCount(Query query, String collectionName) {
1587
1641
1588
1642
/**
1589
1643
* Updates the first object that is found in the specified collection that matches the query document criteria with
1590
- * the provided updated document. <br />
1644
+ * the provided updated document.
1645
+ * <p>
1646
+ * A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
1647
+ * incremented if not explicitly specified in the update.
1591
1648
*
1592
1649
* @param query the query document that specifies the criteria used to select a document to be updated. Must not be
1593
1650
* {@literal null}.
@@ -1605,6 +1662,9 @@ default long exactCount(Query query, String collectionName) {
1605
1662
/**
1606
1663
* Updates all objects that are found in the collection for the entity class that matches the query document criteria
1607
1664
* with the provided updated document.
1665
+ * <p>
1666
+ * A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
1667
+ * incremented if not explicitly specified in the update.
1608
1668
*
1609
1669
* @param query the query document that specifies the criteria used to select a document to be updated. Must not be
1610
1670
* {@literal null}.
@@ -1642,6 +1702,9 @@ default long exactCount(Query query, String collectionName) {
1642
1702
/**
1643
1703
* Updates all objects that are found in the collection for the entity class that matches the query document criteria
1644
1704
* with the provided updated document.
1705
+ * <p>
1706
+ * A potential {@link org.springframework.data.annotation.Version} property of the {@literal entityClass} will be auto
1707
+ * incremented if not explicitly specified in the update.
1645
1708
*
1646
1709
* @param query the query document that specifies the criteria used to select a document to be updated. Must not be
1647
1710
* {@literal null}.
0 commit comments