I noticed a problem in my Spring application, I'm implementing an internal messaging service and when I create the display of the amount of unread messages I realized that the value varied with each update, whenever a new message arrived. In short, whenever an insertion or update occurs I have an intercalation of the outdated ones with the updated ones in each new query made.
Ex: When displaying the amount of messages not read, the result will vary with each update: 1, 2, 1, 2, 1 ...
The same problem is happening in every system, but in other functionalities it is less noticeable.
I've tried to disable the Hibernate cache and give a clear on EntityManager
, but the problem persists.