I have a problem with data not being refreshed. Let us say there are 5 records in the table and when I do findAll(), it returns 5 records as expected but when the hibernate application is running, I go to the database and add one more record manually, the hibernate application is not picking up the sixth record, it still picks up the first 5 only. I had to stop and start my app to get the latest data. why it is happening ?
here is the sample code
cld.createChannelList(form);
ChannelList[] cl = cld.findAll();
System.out.println("*** # records = "+cl.length);
Thread.sleep(30000);
cl = cld.findAll();
System.out.println("*** # records = "+cl.length);
----------------
public java.util.List findAll () throws HibernateException {
Session s = null;
try {
s = getSession();
return findAll(s);
}
finally {
closeSession(s);
}
}
protected java.util.List findAll (Session s) throws HibernateException {
return findAll(s, getDefaultOrderProperty());
}
protected java.util.List findAll (Session s, String orderProperty) throws HibernateException {
Criteria crit = s.createCriteria(getReferenceClass());
if (null != orderProperty) crit.addOrder(Order.asc(orderProperty));
return crit.list();
}
|