Affects Version/s: 4.0.4 (Neumann SR4)
I wanted to use @Version (with long version) to use optimistic locking and kick the CAS of couchbase like mentioned in the documentation.
However, after doing an integrated test, I found out that neither the CASMismatchException or the OptimisticLocking exception are thrown. The problem seems pretty much similar to https://jira.spring.io/browse/DATACOUCH-212.
After searching a bit, it seems that if we want CAS to work, we must use couchbaseOperations.replace... However, the current implement of repositories seems to be using upsert. I was not able to test this theory though.
My integrate test was basically doing:
- Create a User
- Update the token to add one token then save
- Build a new User object with a previous version and a new token and the same id
- Expecting Optimitics lock error but it is save without error