2016-04-15 39 views
0

我在啓動應用程序時遇到錯誤,僅當我在域對象上添加@cache(usage=CacheConcurrencyStrategy.READ_WRITE)註釋時纔得到此例外。如果我只使用註釋@Cacheable(true)它不會給這個錯誤。應用程序中使用了二級緩存,但未提供屬性hibernate.cache.region.factory_class

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

怎麼可能認爲,只要Cacheble它是能夠找到工廠並使用@Cache標註難道不是嗎?

的persistence.xml

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

我使用Hibernate的4.x版本JPA 2.1在JBoss EAP 6

+0

運氣好嗎?你試過解決方案嗎 – LearningPhase

回答

2

能否請您嘗試添加這對你的類。緩存(usage = CacheConcurrencyStrategy.READ_ONLY,region =「employee」)。

將區域名稱更改爲您在encache.xml中使用的名稱

+0

上面的答案有幫助嗎? – LearningPhase

+0

還沒有,無論結果如何,我只會在嘗試時更新你。謝謝回覆。 –

+0

它按照你的建議工作。謝謝 –

相關問題