How to update items in CrudPanel

Viewed 67

In a CrudPanel I have the need to update some items (not through the CRUD dialog). Something like this:

    @Transactional
    ...
 
      instance.setSomeAttribute(newValue);
      return savedInstance = instanceRepository.save(instance);

Calling refreshAll on the dataProvider after the update produces the warning Got an RPC for non-existent node: xxxx. Also I guess it is a little expensive to refresh all items if just one changed.

Calling the specific refresh item, on the other side, refreshItem(instance), gives 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)

I also tried to pass newInstance to refreshItem, same result.

Can somebody indicate how to proceed?

1 Answers

Check equals and hashCode that they don't contain fields that may have changed when you call refreshItem.

Related