@@ -941,6 +941,9 @@ default <T> List<T> findDistinct(Query query, String field, String collection, C
941
941
/**
942
942
* Triggers <a href="https://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify </a>
943
943
* 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.
944
947
*
945
948
* @param query the {@link Query} class that specifies the {@link Criteria} used to find a record and also an optional
946
949
* fields specification. Must not be {@literal null}.
@@ -957,6 +960,9 @@ default <T> List<T> findDistinct(Query query, String field, String collection, C
957
960
/**
958
961
* Triggers <a href="https://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify </a>
959
962
* 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.
960
966
*
961
967
* @param query the {@link Query} class that specifies the {@link Criteria} used to find a record and also an optional
962
968
* fields specification. Must not be {@literal null}.
@@ -975,6 +981,9 @@ default <T> List<T> findDistinct(Query query, String field, String collection, C
975
981
* Triggers <a href="https://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify </a>
976
982
* to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query} taking
977
983
* {@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.
978
987
*
979
988
* @param query the {@link Query} class that specifies the {@link Criteria} used to find a record and also an optional
980
989
* fields specification.
@@ -995,6 +1004,9 @@ default <T> List<T> findDistinct(Query query, String field, String collection, C
995
1004
* Triggers <a href="https://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify </a>
996
1005
* to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query} taking
997
1006
* {@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.
998
1010
*
999
1011
* @param query the {@link Query} class that specifies the {@link Criteria} used to find a record and also an optional
1000
1012
* fields specification. Must not be {@literal null}.
@@ -1387,8 +1399,11 @@ default long exactCount(Query query, String collectionName) {
1387
1399
* leverages Type Conversion API. See
1388
1400
* <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation" > Spring's
1389
1401
* 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>
1392
1407
* The {@code objectToSave} must not be collection-like.
1393
1408
*
1394
1409
* @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) {
1404
1419
* The object is converted to the MongoDB native representation using an instance of {@see MongoConverter}. Unless
1405
1420
* configured otherwise, an instance of {@link MappingMongoConverter} will be used. <br />
1406
1421
* 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>
1408
1425
* The {@code objectToSave} must not be collection-like.
1409
1426
*
1410
1427
* @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) {
1416
1433
1417
1434
/**
1418
1435
* 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.
1419
1441
*
1420
1442
* @param batchToSave the batch of objects to save. Must not be {@literal null}.
1421
1443
* @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) {
1427
1449
1428
1450
/**
1429
1451
* 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.
1430
1457
*
1431
1458
* @param batchToSave the list of objects to save. Must not be {@literal null}.
1432
1459
* @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) {
1437
1464
/**
1438
1465
* Insert a mixed Collection of objects into a database collection determining the collection name to use based on the
1439
1466
* 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.
1440
1472
*
1441
1473
* @param objectsToSave the list of objects to save. Must not be {@literal null}.
1442
1474
* @return the inserted objects.
@@ -1454,14 +1486,20 @@ default long exactCount(Query query, String collectionName) {
1454
1486
* String then MongoDB ObjectId will be used to populate that string. Otherwise, the conversion from ObjectId to your
1455
1487
* property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See
1456
1488
* <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>
1458
1494
* The {@code objectToSave} must not be collection-like.
1459
1495
*
1460
1496
* @param objectToSave the object to store in the collection. Must not be {@literal null}.
1461
1497
* @return the saved object.
1462
1498
* @throws IllegalArgumentException in case the {@code objectToSave} is collection-like.
1463
1499
* @throws org.springframework.data.mapping.MappingException if the target collection name cannot be
1464
1500
* {@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.
1465
1503
*/
1466
1504
<T > T save (T objectToSave );
1467
1505
@@ -1474,19 +1512,29 @@ default long exactCount(Query query, String collectionName) {
1474
1512
* String then MongoDB ObjectId will be used to populate that string. Otherwise, the conversion from ObjectId to your
1475
1513
* property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See
1476
1514
* <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>
1478
1520
* The {@code objectToSave} must not be collection-like.
1479
1521
*
1480
1522
* @param objectToSave the object to store in the collection. Must not be {@literal null}.
1481
1523
* @param collectionName name of the collection to store the object in. Must not be {@literal null}.
1482
1524
* @return the saved object.
1483
1525
* @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.
1484
1528
*/
1485
1529
<T > T save (T objectToSave , String collectionName );
1486
1530
1487
1531
/**
1488
1532
* 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>
1490
1538
* <strong>NOTE:</strong> {@link Query#getSortObject() sorting} is not supported by {@code db.collection.updateOne}.
1491
1539
* Use {@link #findAndModify(Query, UpdateDefinition, FindAndModifyOptions, Class, String)} instead.
1492
1540
*
@@ -1528,6 +1576,9 @@ default long exactCount(Query query, String collectionName) {
1528
1576
/**
1529
1577
* Performs an upsert. If no document is found that matches the query, a new document is created and inserted by
1530
1578
* 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.
1531
1582
*
1532
1583
* @param query the query document that specifies the criteria used to select a record to be upserted. Must not be
1533
1584
* {@literal null}.
@@ -1545,6 +1596,9 @@ default long exactCount(Query query, String collectionName) {
1545
1596
/**
1546
1597
* Updates the first object that is found in the collection of the entity class that matches the query document with
1547
1598
* 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.
1548
1602
*
1549
1603
* @param query the query document that specifies the criteria used to select a record to be updated. Must not be
1550
1604
* {@literal null}.
@@ -1583,7 +1637,10 @@ default long exactCount(Query query, String collectionName) {
1583
1637
1584
1638
/**
1585
1639
* 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.
1587
1644
*
1588
1645
* @param query the query document that specifies the criteria used to select a record to be updated. Must not be
1589
1646
* {@literal null}.
@@ -1601,6 +1658,9 @@ default long exactCount(Query query, String collectionName) {
1601
1658
/**
1602
1659
* Updates all objects that are found in the collection for the entity class that matches the query document criteria
1603
1660
* 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.
1604
1664
*
1605
1665
* @param query the query document that specifies the criteria used to select a record to be updated. Must not be
1606
1666
* {@literal null}.
@@ -1638,6 +1698,9 @@ default long exactCount(Query query, String collectionName) {
1638
1698
/**
1639
1699
* Updates all objects that are found in the collection for the entity class that matches the query document criteria
1640
1700
* 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.
1641
1704
*
1642
1705
* @param query the query document that specifies the criteria used to select a record to be updated. Must not be
1643
1706
* {@literal null}.
0 commit comments