I have a struts application that uses Hibernate to access a MYSQL DB. I have a number of pages that make changes to the DB. These changes go through fine, data is update in the DB. However when browsing to the page that should show this updated information its often not there, and even after a few page refreshes it still isn't there. Eventually it will turn up. I'm assuming this has something to do with hibernate caching data, but how can I ensure that data is up to date? I had assumed that as it all went through the hibernate session it would pick up changes? The code i'm using to do the update is :
hSession = HibernateUtil.getSessionFactory().getCurrentSession();
Transaction tx = hSession.getTransaction();
tx.begin();
hSession.update(user) ;
Then to pull that user out again:
org.hibernate.Session hSession = HibernateUtil.getSessionFactory()
.getCurrentSession();
Transaction tx = hSession.beginTransaction();
User u= (User) hSession.load(User.class, userID);