Hello,
I'm having problems with query results staying cached. We have outside processes updating the database, so we need a fresh read on certain queries each time. I've tried the following to force fresh reads, but still get stale results.
Code:
Query q = HibernateUtil.getSession().getNamedQuery("getBalance");
q.setCacheMode(CacheMode.REFRESH);
q.setString("provider", provider);
q.setString("customer", customer);
List balances = q.list();
I've also tried:
HibernateUtil.getSessionFactory().evictQueries();
Query q = HibernateUtil.getSession().getNamedQuery("getBalance");
q.setString("provider", provider);
q.setString("customer", customer);
List balances = q.list();
Hibernate version: 3.0
Mapping documents:
<session-factory>
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.password">bar</property>
<property name="hibernate.connection.url">jdbc:mysql://server1.mycompany.com:3306/myDb</property>
<property name="hibernate.connection.username">foo</property>
<property name="hibernate.dialect">com.talkplus.pmp.util.MySQL5Dialect</property>
<property name="hibernate.show_sql">false</property>
<property name="cache.use_query_cache">false</property>
</session-factory>
Name and version of the database you are using:
MySQL 5.0
What am I missing?
Thanks.
Kris
|