Hi,
I have setup hibernate query cache. But when I execute the
same query multiple times, it still go and query the database (from
the hibernate sql out in the console, it still executes mysql query).
Can you please tell me what am i missing?
Here is why I did in my hibernate.cfg.xml file:
Add these:
<property name="cache.provider_class">
org.hibernate.cache.EhCacheProvider
</property>
<property name="hibernate.cache.use_query_cache">true</property>
And then, here is my query:
Query query = session
.createQuery(
"from Country as country where country.language= :language and
country.phone.id = :phoneid");
query.setString("language", language).setLong("phoneid",
phone.getId().longValue());
query.setCacheable(true);
// uncomment this still does not work.
// query.setCacheRegion("query.Builds");
List result = query.list();
Can you please tell my how to get ehcache to work as hibernate query cache.
I think I have followed what the documentation said. But it still does not work.
Thank you.
|