hibernate createSQLQuery use CacheQuery?
Query query=getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(
"select...
getHibernateTemplate().setCacheQueries(true);
List result= query.list();
getHibernateTemplate().setCacheQueries(f开发者_JAVA百科alse);
return result;
may i know when i do manual "createSQLQuery" how to use cacheQuery? the above doesnt cache the result. show_sql still showing every request get from database
AFAIK when using createSQLQuery, you must use an explicit .addScalar or .addEntity if setCacheable is true, or hibernate gets confused on casting. Apart from that, my understanding is that it should work.
Try to configure ApplicationContext
<prop key="hibernate.cache.provider_class">org.hibernate .cache.EhCacheProvider</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
加载中,请稍侯......
精彩评论