Hi
I am having a strange problem in Hibernate.
I have a web app that is running in a load-balancing environment. So there are two physical servers responding to web requests.
In the application, there is an action that updates a record, the hibernate code is doing:
Code:
session.save(loan);
session.flush();
session.connection().commit();
then there is another action that retrieves the list of objects:
Code:
allLoans = session.find("from Loan as Loan where status='a'");
but sometimes (due to the load balancing I guess), the application shows the previous version of the data, before the update, that is probably returning cached data, because if I refresh the page, it shows the correct updated information, when the request goes to the other server, and the session.find loads fresh data.
So this looks to me like somehow the data is being cached by one server, because in reality there are two hibernate session running... one on each server.
Is there a way to force Hibernate to return fresh data in a "session.find()" ?
I even added a "session.flush()" before doing the "session.find()" but that didn't help.
Is there some other thing that I am missing here?
Thanks,