2

I am trying to implement hibernate 2nd level cache in my application.

pom.xml

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

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>4.1.5.Final</version>
</dependency>

persistence.xml

<property name="hibernate.cache.region.factory_class" value="net.sf.ehcache.hibernate.EhCacheRegionFactory"/>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.SingletonEhCacheProvider"/>
<property name="hibernate.cache.use_second_level_cache" value="true"/>
<property name="hibernate.cache.use_query_cache" value="true"/>
Andrey Korneyev
  • 26,353
  • 15
  • 70
  • 71
rocky
  • 103
  • 1
  • 3
  • 10
  • 2
    Are those versions compatible with each other? One is `4.1.5` and the other is `4.3.8`. – Kayaman Apr 01 '15 at 10:03
  • @kayaman: I don't know as i am working on it first time. – rocky Apr 01 '15 at 10:13
  • Well, maybe you should find out. A class is missing and your libraries differ by 2 minor versions. What do you think that means? – Kayaman Apr 01 '15 at 10:15
  • Possible duplicate of: http://stackoverflow.com/questions/11905722/java-lang-noclassdeffounderror-org-hibernate-cache-entityregion-configuring-ehc (implying a version conflict) – JBA Apr 01 '15 at 10:17

1 Answers1

2

from hibernate 4, in persistance.xml

<property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.ehcache.EhCacheRegionFactory"/> 
Frizz1977
  • 1,121
  • 13
  • 21