Explanation: the problem is that with ReadWrite Access strategy the insertion of a new cache entry get deferred to afterTransactionCompletion. (see NaturalIdReadWriteAccess.java methods insert and afterInsert). Thus the order of insert/delete get inverted:
- ActionQueue processes inserts → insertion of a new cache entry get deferred to afterTransactionCompletion.
- ActionQueue processes deletes→ removal of according cache entry (does not exist yet)
- afterTransactionCompletion process → insertion of a cache entry with obsolete value
Later when creating a new instance with same NaturalId then the cache get not updated bacause of the existing entry. As we see in the code below from NaturalIdReadWriteAccess.java the entry will only be created if not existing already.
|