在 CrudPanel 中,我需要更新一些项目(不是通过 CRUD 对话框)。像这样的事情:
@Transactional
...
instance.setSomeAttribute(newValue);
return savedInstance = instanceRepository.save(instance);
更新后在 dataProvider 上调用refreshAll会产生警告Got an RPC for non-existent node: xxxx
。另外,我认为如果只更改一项,则刷新所有项目会有点贵。
调用特定的刷新项,在另一边,refreshItem(instance)
,给出类 [...MenuItem] 的对象,标识符为 [xxxx]:乐观锁定失败;嵌套异常是 org.hibernate.StaleObjectStateException:行已被另一个事务更新或删除(或未保存值映射不正确)
我还尝试将newInstance
传递给refreshItem,结果相同。
有人可以指示如何进行吗?
最佳答案
检查equals
和hashCode
,确保它们不包含在您调用refreshItem
时可能已更改的字段。
关于vaadin - 如何更新 CrudPanel 中的项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69251299/