|
CouchDB implicitely works with optimistic locking for all documents. For that purpose there is the _rev attribute which is updated on the server side upon each write. When updating a document with a non-current revision, a HTTP 409 error is returned.
As the attribute is maintained by the database, its value won't be up to date after inserts/updates atm. without manually reading back the entity. This can be addressed by adding support for generated properties via the existing @Generated annotation (implement OgmEntityPersister#processInsertGeneratedProperties() and processUpdateGeneratedProperties()).
In CouchDBDialect#updateTuple(), the entity currently is always read prior to the update, which would discard any previously read revision id. This needs to be changed to do the load only if the entity doesn't contain the original revision.
|