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
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.
In my case I had unneeded persistence.xml file in subproject that was making wildfly wild - it was overriding configuration file.
Property <entry key="hibernate.cache.region.factory_class" value="org.hibernate.cache.ehcache.EhCacheRegionFactory"/>
was completely ignored. After removing(renaming) persistence.xml, wildfly would start again correctly with properties from database.xml. Hope it saves you some time (Wildfly 9.0.1Final, Hibernate 4.3.6.Final)
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.