JPA二级缓存在wildfly8.2中,hibernate-entitymanager 4.3.8.Final [英] JPA second level cache in wildfly8.2, hibernate-entitymanager 4.3.8.Final
问题描述
我试图在wildfly8.2中使用二级缓存
我通过JavaConfig设置属性
Properties properties = new Properties();
properties.setProperty(hibernate.hbm2ddl.auto,hibernateHbm2ddlAuto);
properties.setProperty(hibernate.dialect,hibernateDialect);
properties.setProperty(hibernate.show_sql,true);
properties.setProperty(hibernate.cache.use_second_level_cache,true);
properties.setProperty(hibernate.cache.use_query_cache,true);
但我得到以下错误:
- 引起:org.hibernate.cache.NoCacheRegionFactoryAvailableException:在应用程序中使用二级缓存,但未给出属性hibernate.cache.region.factory_class;请使用hibernate.cache.region.factory_class设置禁用二级缓存或设置正确的区域工厂,并确保二级缓存提供程序(例如hibernate-infinispan)在类路径中可用。
为什么按照文档给出错误并不是必需的。任何输入都会有帮助。
感谢
Sanjeev。
Configuration.setProperty(hibernate.cache.region.factory_class,net.sf.ehcache.hibernate.EhCacheRegionFactory)
我会使用C3P0或Infinispam作为二级缓存。
I am trying to use second level cache in wildfly8.2 I am setting the properties via JavaConfig Properties properties = new Properties(); properties.setProperty("hibernate.hbm2ddl.auto", hibernateHbm2ddlAuto); properties.setProperty("hibernate.dialect", hibernateDialect); properties.setProperty("hibernate.show_sql", "true"); properties.setProperty("hibernate.cache.use_second_level_cache", "true"); properties.setProperty("hibernate.cache.use_query_cache" , "true");
but I get the following error
- Caused by: 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 using the hibernate.cache.region.factory_class setting and make sure the second level cache provider (hibernate-infinispan, e.g.) is available on the classpath.
Why is it giving that error as per documentation it is not required. Any input would be helpful.
JPA shared cache / second level cache in WildFly
Thanks Sanjeev.
You need to define the property hibernate.cache.region.factory_class, something like:
Configuration.setProperty("hibernate.cache.region.factory_class", "net.sf.ehcache.hibernate.EhCacheRegionFactory")
I would use C3P0 or Infinispam as second level cache.
这篇关于JPA二级缓存在wildfly8.2中,hibernate-entitymanager 4.3.8.Final的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!