首页 > 解决方案 > 如何更新 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,结果相同。

有人可以指出如何进行吗?

标签: vaadincrudupdates

解决方案


检查equalshashCode确保它们不包含在您调用时可能已更改的字段refreshItem


推荐阅读