DATAMONGO-2195 - Throw OptimisticLockingFailureException on delete only in repositories.
OptimisticLockingFailureException is now thrown only when deleting an entity through a repository and no longer when using the Template API. Original pull request: #641.
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
* <<mongodb.reactive.repositories.queries.type-safe,Querydsl support for reactive repositories>> via `ReactiveQuerydslPredicateExecutor`.
|
||||
* <<reactive.gridfs,Reactive GridFS support>>.
|
||||
* Extended SpEL aggregation support for MongoDB 3.4 and MongoDB 4.0 operators (see <<mongo.aggregation.projection.expressions>>).
|
||||
* Template API delete by entity considers the version property in delete queries.
|
||||
* Repository deletes now throw `OptimisticLockingFailureException` when a versioned entity cannot be deleted.
|
||||
|
||||
[[new-features.2-1-0]]
|
||||
== What's New in Spring Data MongoDB 2.1
|
||||
|
||||
@@ -1080,11 +1080,12 @@ template.save(tmp); // throws OptimisticLockingFailureException
|
||||
|
||||
IMPORTANT: Optimistic Locking requires to set the `WriteConcern` to `ACKNOWLEDGED`. Otherwise `OptimisticLockingFailureException` can be silently swallowed.
|
||||
|
||||
NOTE: As of Version 2.2 `MongoOperations` also includes the `@Version` property when removing an entity from the database, raising an
|
||||
`OptimisticLockingFailureException` if a document with matching `_id` but a `version` mismatch shall be deleted. In cases
|
||||
where no Document with matching `_id` can be found the operation passes without error.
|
||||
NOTE: As of Version 2.2 `MongoOperations` also includes the `@Version` property when removing an entity from the database.
|
||||
To remove a `Document` without version check use `MongoOperations#remove(Query,...)` instead of `MongoOperations#remove(Object)`.
|
||||
|
||||
NOTE: As of Version 2.2 repositories check for the outcome of acknowledged deletes when removing versioned entities.
|
||||
An `OptimisticLockingFailureException` is raised if a versioned entity cannot be deleted through `CrudRepository.delete(Object)`. In such case, the version was changed or the object was deleted in the meantime. Use `CrudRepository.deleteById(ID)` to bypass optimistic locking functionality and delete objects regardless of their version.
|
||||
|
||||
[[mongo.query]]
|
||||
== Querying Documents
|
||||
|
||||
|
||||
Reference in New Issue
Block a user