sbrattla wrote:
Hi,
As far as i've understood, a query cache will expire whenever you change something in the table(s) that your cached query depends on.
Furthermore, you can configure the query cache in your ehcache.xml (if that is the cache provider your'e using):
Code:
<cache
name="org.hibernate.cache.StandardQueryCache"
maxElementsInMemory="2500"
eternal="false"
timeToLiveSeconds="900"
overflowToDisk="false"
/>
How would Hibernate know that something has changed in the underlying tables if it is using that cache? I have set the default cache to this and activated the 2nd level cache:
Code:
<defaultCache
maxElementsInMemory="5000"
eternal="false"
timeToLiveSeconds="15"
overflowToDisk="false"
diskPersistent="false"
memoryStoreEvictionPolicy="LFU"
>
However, if I change something in the table, it is not reflected in the entities. Here are the settings in persistence.xml:
Code:
<property name="hibernate.cache.provider_class" value="net.sf.ehcache.hibernate.SingletonEhCacheProvider"/>
<property name="hibernate.cache.use_second_level_cache" value="true"/>
<property name="hibernate.cache.use_query_cache" value="false"/>
<property name="hibernate.generate_statistics" value="true"/>
<property name="hibernate.cache.provider_configuration_file_resource_path" value="ehcache.xml"/>
Why isn't the cached cleared?
Thanks
Markus