Hi Hibernate Experts,
I am having problem applying the cache when using Native Query that returns non entity objects.
When I see the log, it said:
DEBUG 2007-07-23 18:56:47,050 org.hibernate.cache.StandardQueryCache - checking cached query results in region: query.abc
DEBUG 2007-07-23 18:56:47,050 org.hibernate.cache.EhCache - key: sql: SELECT as_id AS articleId ..... (truncated by me)
DEBUG 2007-07-23 18:56:47,050 org.hibernate.cache.StandardQueryCache - query results were not found in cache
DEBUG 2007-07-23 18:56:47,394 org.hibernate.cache.StandardQueryCache - caching query results in region: query.abc; timestamp=4854619369676800
....
....
that's ok, first try - the cache should not be there
....
but again i execute the same url, the logs repeat with the same message, that it said query results were not found in cache.
Here is the piece of codes which executing the query:
return getHibernateTemplate().executeFind(
new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException, SQLException {
Query query = session.getNamedQuery("myquery");
query.setParameter("A", a)
.setParameter("siteId", siteId)
.setCacheable(true) .setCacheRegion("query.abc") .setResultTransformer(Transformers.aliasToBean(MyResult.class));
return query.list();
}
}
);
and the region configuration:
<cache name="query.abc"
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="14400"
timeToLiveSeconds="14400"
overflowToDisk="true"
/>
Now my question what is wrong? do i miss something? or is Hibernate able to cache result from Native sql and the results are basically not an entity?
Thank you :)
|