| When the cachemode is set to CacheMode.GET and an entity is updated, the entity is not evicted from the cache. Therefore, when the entity is updated by another transaction afterwards, an exception occurs:
org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)
The problem might have to do with the execute-method in org.hibernate.action.internal.EntityUpdateAction (line 188). The bug can be reproduces by project: https://github.com/topicusonderwijs/cachetest. When deployed, take the following steps:
- Click on the New MyEntity-button. A new MyEntity-instance is inserted in the database;
- Click on the Update last MyEntity-button. The last created MyEntity-instance is updated with CacheMode.GET;
- Click on the Update last MyEntity-button. An error occurs.
|