Hibernate version: Hibernate 3.2.4.sp1
I am using Hibernate as part of the Seam framework. My problem is when a field is updated by an external application the change is not reflected in the web interface.
For example, I display a data table backed by a query:
Code:
entityManager.createQuery("select c from Channel c").getResultList();
Then after changing a Channel field using an external application and refreshing the page, I see the same stale result from the first query.
However, if I do:
Code:
entityManager.clear();
entityManager.createQuery("select c from Channel c").getResultList();
The fields are refreshed from the database.
I believe Hibernate is pulling the results from its session cache, so I've tried to turn off the session cache by adding the following to my persistence.xml file:
Code:
<property name="hibernate.cache.use_second_level_cache" value="false" />
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider" />
and it appears to be disabled when the application starts:
Code:
16:43:41,839 INFO [SettingsFactory] Second-level cache: disabled
16:43:41,840 INFO [SettingsFactory] Query cache: disabled
but they have no effect.
I can hack around this by sprinkling entityManager.clear() and entityManager.refresh(c) throughout my code, but I'd prefer to set a configuration option and have the changes application wide.
Can someone point me in the right direction?
Thanks,
Dan