假设您有一个文档:
@Document(collection = "person-document", touchOnRead = true)
public class PersonDocument {
@Id
long id;
@Field
String transaction;
}
这就是创建实体的方式:
PersonDocument person = new PersonDocument(1L, "112e-dfsc-3442-cwce-3434");
repository.save(person);
这就是您尝试更新实体的方式:
PersonDocument person = repository.findOne(1L);
person.setTransaction(null);
repository.save(person);
但是,后者不会删除“transaction”的 bin 值,并且值“112e-dfsc-3442-cwce-3434”仍然存在于数据存储中。
解决方法 - 用空字符串更新值,但是考虑到 spring data 的其他实现(特别是 spring-data-jpa)的工作方式,这有点令人困惑。
如果实体字段设置为 NULL,那么删除 bin 值而不是保留旧值不是更好吗?因为现在 NULL
属性在更新期间被丢弃。
最佳答案
请考虑使用最新版本的spring-data-aerospike .
这应该不是问题,我刚刚检查过该场景是否正常工作。 如果您仍然发现问题,请开票并提供测试用例。
关于java - Spring-data-aerospike 无法将字段设置为 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52892460/