vaadin - 如何更新 CrudPanel 中的项目
问题描述
在 CrudPanel 中,我需要更新一些项目(不是通过 CRUD 对话框)。像这样的东西:
@Transactional
...
instance.setSomeAttribute(newValue);
return savedInstance = instanceRepository.save(instance);
更新后在 dataProvider 上调用 refreshAll 会产生警告Got an RPC for non-existent node: xxxx
。此外,我想如果只更改一项,刷新所有项目会有点贵。
另一方面,调用特定的刷新项,refreshItem(instance)
给出Object of class [...MenuItem] with identifier [xxxx]: optimistic locking failed; nested exception is org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)
我也尝试传递newInstance
给 refreshItem,结果相同。
有人可以指出如何进行吗?
解决方案
检查equals
并hashCode
确保它们不包含在您调用时可能已更改的字段refreshItem
。
推荐阅读
- r - 如何使用 R 客户端连接到 Docker Influxdb?
- pandas - 根据值获取列索引标签
- amazon-web-services - AWS Python 3.7 Lambda 使用 boto3:workmailmessageflow - UnknownServiceError
- python - Bokeh 是否允许节点成为 Networkx 中的“任何可散列对象”?
- javascript - jquery 查找所有具有类的元素并返回单击元素的计数位置
- vba - 多个布尔语句 VBA
- sql - SQL 查询以选择第二次出现
- sql - 有条件地使用 CASE...WHEN - Oracle SQL
- c++ - SimpleITK 在 C++ 中找不到 ITK 函数
- go - 如果我按值而不是指针返回,Go 会复制我的结构吗?