I am using PostUpdateEventListener registered through
registry.appendListeners(EventType.POST_COMMIT_UPDATE, listener)
and a few other listeners to track changes made by Hibernate. This works great, however, I see a problem there:
Say to track some amount on id I just do
amountByIdConcurrentMap.put(id, amount);
on each POST_COMMIT_UPDATE (let other operations be ignored). The problem is that this call happens some time after the commit. Thus, with two commits that write the same object immediately one after another, I can receive events in the wrong order, eventually saving the old amount .
- Is this really possible or are the operations synchronized in some way?
- Is there any way to prevent or at least detect such a situation?
source share