0

I'm following a tutorial using second-level cache of Hibernate. The hibernate version is hibernate-core-4.3.10.Final.jar.But when I configure it in hibernate.cfg.xml with properties hibernate.cache.provider_class. The value should be org.hibernate.cache.EhCacheProvider according to the tutorial. But in my case, I can't find this class. I checked the jar file and didn't find this class in it.

Does anyone know where it's placed? Is it changed because of the version?

When I searched this issue online, I found that there's other ways configuring the second-level cache of Hibernate. It will be grateful if you can explain this as well.

Thanks in advance.

Sky
  • 7,343
  • 8
  • 31
  • 42

1 Answers1

0

In the ehcache site you will find documentation about hibernate integration.

For Hibernate 4 use org.hibernate.cache.ehcache.EhCacheRegionFactory

Also check that you have the correct hibernate-ehcache library. If you are using maven, the dependency for H4 is:

<dependency>
   <groupId>org.hibernate</groupId>  
   <artifactId>hibernate-ehcache</artifactId>
   <version>4.0.0</version>
</dependency>

Edit: here is a guy that get all the needed libaries directly from ehcache distribution zip, maybe is your case.

Guillermo
  • 1,523
  • 9
  • 19
  • Yes, I noticed this. After copied all the jars into my classpath, it still can't find the class EhCacheProvider. So I'm not sure what happened here. Thanks for your answer and I will try it out. As you said, the class I used in my configuration file is available in the previous version of Hibernate? – Sky Jul 06 '15 at 07:25
  • I just get confused. I edit the answer, take a look to the added link. Regards – Guillermo Jul 06 '15 at 08:40