I\'m trying to add ehcache
(v2.6.0) to my Hibernate 4.1.5.SP1
project, but having some configuration issues. Specifically, I\'m getting a ja
Configuration.setProperty("hibernate.cache.region.factory_class",
"net.sf.ehcache.hibernate.EhCacheRegionFactory")
For Hibernate 4, use
org.hibernate.cache.ehcache.EhCacheRegionFactory instead of net.sf.ehcache.hibernate.EhCacheRegionFactory
Hibernate Configuration Article
ehcache-core files are basically for Hibernate 3.x. Hibernate 4.x comes with its own implementation for ehcache. You don't need to use ehcache explicitly in hibernate 4.x. Here is the best answer for your problem.
http://web.archive.org/web/20130117102553/http://www.javacraft.org/2012/03/migrate-to-hibernate-4-ehcache.html
From Hibernate 4, there s new hibernate-cache introduce for caching. This need latest dependency for net.sf.ehcache
upto 2.6. Following article will CLICK ON LINK.
When i add following dependency in my pom, the error will remove:
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.8.3</version>
</dependency>
I checked maven the dependencies. Maven always loads ehcache-code when the hibernate-ehcache package is loaded.
Dependency tree:
+--- org.hibernate:hibernate-ehcache:4.3.0.Final
| +--- org.jboss.logging:jboss-logging:3.1.3.GA
| +--- org.jboss.logging:jboss-logging-annotations:1.2.0.Beta1
| +--- org.hibernate:hibernate-core:4.3.0.Final (*)
| \--- net.sf.ehcache:ehcache-core:2.4.3
| \--- org.slf4j:slf4j-api:1.6.1 -> 1.6.6
Please check your persistence configuration. It should not include any classes where the package name starts with "net.sf"
For example, you have to replace the following string in your code:
.setProperty("hibernate.cache.region.factory_class", "net.sf.ehcache.hibernate.EhCacheRegionFactory")
with the following string:
.setProperty("hibernate.cache.region.factory_class", "org.hibernate.cache.ehcache.EhCacheRegionFactory")