Hi,
We have some data that is updated to a table from a web-page, the updates are correctly reflected in the database, but when the page is reloaded, some old values show up on the screen.
Interestingly there is a strange pattern, on clicking on the update button repeatedly without modifying the data the previous value(value before the first update) shows up every 5th time.
When the same is done with different data each time, the data shown up on the screen is one amongst the last 5 updates.
Presume this has something to do with the way the data is cached. But we have not done anything to enable caching.
The hibernate mappings are straight and simple with no mapping dependency to any other table.
The mapping-
Code:
<hibernate-mapping>
<class name="com.ReferralRow" table="REFERRAL">
<id name="refUid" column="REF_UID" type="long">
<generator class="sequence">
<param name="sequence">REF_SEQ</param>
</generator>
</id>
<property name="optionUid" column="OPTION_UID" type="long"/>
......
..... more independent fields
.....
The update code is as follows-
Code:
Session session = HibernateSession.currentSession();
ReferralRow referral = (ReferralRow)session.load(ReferralRow.class,new Long(iRefNo));
referral.setOptionUid(someValue);
set some other fields ...
session.flush();
After update, the retrieve often shows up old values on screen.
Code:
Session session = HibernateSession.currentSession();
List list = session.find("from referral in class com.ReferralRow where referral.optionUid= ?", new Long(optionUid), Hibernate.LONG);
...
set values into a VO..
session.flush();
We're passing a connection object fetched from a connection-pool to Hibernate. Both the update and the fetch happen within the same transaction.
Is there something fundamentally wrong with the code? Why could the old data show up on screen at regular intervals?
-Thanks in adv.