我正在使用 spring data 从 couchbase 获取文档,我需要将检查和设置元数据字段 cas 映射到我的文档,以实现乐观锁。
如何在不使用 n1ql 查询的情况下做到这一点?
谢谢
最佳答案
我不是 Java 开发人员,但看了一眼 Spring.io docs for Spring Data Couchbase :
If you want automatic optimistic locking support, all you need to do is add a @Version annotation on a long field like this:
Example 15. A Document with optimistic locking.
@Document public class User { @Version private long version; // constructor, getters, setters... }
If you load a document through the template or repository, the version field will be automatically populated with the current CAS value.
关于java - 比较和交换: How to map the cas metadata field to document entity of my couchbase,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54411880/