Dear guru,
I am trying to use query cache and have found it not working in my configuration. Below are details.
Mapping:
Code:
<class name="IdNameDto"
entity-name="UserStatus"
table="user_status"
mutable="false">
<id name="id" column="user_status_id" type="integer" />
<property name="name" column="user_status_name" type="string" />
</class>
Query:
Code:
session.createQuery("From UserStatus order by name")
.setCacheable(true)
.list()
EHCache.xml
Code:
<cache
name="org.hibernate.cache.StandardQueryCache"
maxElementsInMemory="5000"
eternal="false"
timeToLiveSeconds="3600"
diskPersistent="false"
overflowToDisk="true"/>
<cache
name="org.hibernate.cache.UpdateTimestampsCache"
maxElementsInMemory="5000"
eternal="true"
diskPersistent="false"
overflowToDisk="true"/>
This query is executed in read-only transactional context and cached by StandardQueryCache. I noticed that UpdateTimestampsCache is always invalidated _after_query is cached that's why last update timestamp is always greater than query timestamp and cached resultset is always considered as not up to date. As a result query is fetched from database again.
Could you please tell me what's wrong?
Thanks in advance,
Vadim[/code]