简体   繁体   中英

Configure Query Cache in Hibernate4

I'm trying enable query cache in our application. As per the documentation I have given

hibernate.cache.use_query_cache as true and givent setCacheable() in my queries. But I'm getting below exception.

org.hibernate.cache.NoCacheRegionFactoryAvailableException: Second-level cache is used in the application, but property hibernate.cache.region.factory_class is not given, please either disable second level cache or set correct region factory class name to property hibernate.cache.region.factory_class (and make sure the second level cache provider, hibernate-infinispan, for example, is available in the classpath).

Should I specify cache region for query cache, I'm using Hibernate 4. Please help me in this regard

Use Following for hibernate 4.

I am using this with hibernate 4.3

    <property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property>
  <property name="hibernate.cache.use_second_level_cache">true</property>
  <property name="hibernate.cache.use_query_cache">true</property>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM