I\'m using Spring + JPA + Hibernate. I\'m trying to enable Hibernate\'s second level cache. In my Spring\'s applicationContext.xml
I have:
This link helped me for using second level cache with Hibernate 4
Try this:
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.max_fetch_depth">4</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.region.factory_class">net.sf.ehcache.hibernate.EhCacheRegionFactory</prop>
And if you are using Maven add this to your POM file:
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.3.0</version>
</dependency>
Or download the latest jar from http://ehcache.org/
I didn't answer this, but it's not obvious that the poster found the answer himself. I'm reposting his answer:
Since I'm using LocalEntityManagerFactoryBean
it gets its settings from META-INF/persistence.xml
. My settings in applicationContext.xml
weren't even being read.