应用程序中使用了二级缓存,但未给出属性hibernate.cache.region.factory_class

时间:2016-04-15 10:28:26

标签: hibernate ehcache

启动应用程序时出现以下错误,只有在域对象上添加@cache(usage=CacheConcurrencyStrategy.READ_WRITE)注释时才会出现此异常。如果我只使用注释@Cacheable(true),则不会出现此错误。

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"/>

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

1 个答案:

答案 0 :(得分:4)

你可以尝试将它添加到你的班级。缓存(usage = CacheConcurrencyStrategy.READ_ONLY,region =“employee”)。

将区域名称更改为您在encache.xml中使用的名称

相关问题