2014-04-22 37 views
0

我試圖在我們的應用程序中啓用查詢緩存。根據我提供的文件在Hibernate4中配置查詢緩存

hibernate.cache.use_query_cache作爲true和給予setCacheable()在我的查詢。但我得到了異常。

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).

我應該指定緩存區的查詢緩存,我使用Hibernate 4.請幫我在這方面

+1

請參閱[this](http://stackoverflow.com/questions/19303348/hibernate-nocacheregionfactoryavailableexception) – Reimeus

回答

2

使用後的休眠4.

我用這與休眠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>