We are using Hibernate with Spring for our Java application. We find out that when a session update something in database other sessions can not see the update.
For example user1 get the account balance from database then user2 increase the balance , if user1 get the object another time he see the account balance before updating (seems that session use the value from its cache) but we want to get the updated object with new account balance.
User1 use one session during all activity that is different from user2 session.
Is any configuration to force to get the updated object from database? or any other help?
We are using Hibernate with Spring for our Java application. We find out that
Share
That is by design (think of Session as “unit of work”); Sessions should be transactionally isolated. That is one of the vast many reasons Sessions should be short lived. Sounds to me like you might be using long lived Sessions.
But in any case, you can force the “other session” (user1 in your case) to refresh its state of the Account using
session.refresh( theAccount );. REFRESH is a cascadeable action too, if you need dependent state to be refreshed as well when you refresh Account…