正如在spring data couchbase参考指南中提到的,我试图使用@Version注释启用乐观锁定功能。我的期望是couchbase将填充版本字段,当一个doucument发生了变化。但似乎它不是填充版本字段。它总是0.以下是我的Pojo,并使用crudRepository来保存文档。当我更新我尝试发送版本为1来模拟optimitic锁定异常。但我没有得到任何异常的更新进展良好。由于文件没有多大帮助,我无法继续前进。任何帮助将不胜感激?乐观锁定不适用于弹簧数据couchbase @version
@Document
public class Project extends BusinessEntity {
private static final long serialVersionUID = 1665165729053936288L;
@NotNull
@Field
private String name;
@Field
private String description;
@Version
private long version;
public Project() {
}
public Project(String name) {
this.name = name;
}
public Project(String name, String description) {
super();
this.name = name;
this.description = description;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the description
*/
public String getDescription() {
return description;
}
/**
* @param description the description to set
*/
public void setDescription(String description) {
this.description = description;
}
/**
* @return the version
*/
public long getVersion() {
return version;
}
/**
* @param version the version to set
*/
public void setVersion(long version) {
this.version = version;
}
}
你可以扩展你的答案吗?我有同样的问题,但不太明白你如何解决它。 – DavidR 2017-09-28 04:55:47