I'm using Spring + JPA + Hibernate. I'm trying to enable Hibernate's second level cache. In my Spring's applicationContext.xml I have:
When I run I get the error:Code:<prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.SingletonEhCacheProvider</prop> <prop key="hibernate.cache.provider_configuration_file_resource_path">/ehcache.xml</prop>
So it's complain I don't have second level cache enabled. So I add to my applicationContext.xml to enable it:Code:Caused by: org.hibernate.HibernateException: Could not instantiate cache implementation at org.hibernate.cache.CacheFactory.createCache(CacheFactory.java:64) Caused by: org.hibernate.cache.NoCachingEnabledException: Second-level cache is not enabled for usage [hibernate.cache.use_second_level_cache | hibernate.cache.use_query_cache] at org.hibernate.cache.NoCacheProvider.buildCache(NoCacheProvider.java:21)
But still no joy. I also tried adding this to my ehcache.xml:Code:<prop key="hibernate.cache.use_second_level_cache">true</prop>
But it still doesn't work.Code:<property name="hibernate.cache.use_second_level_cache">true</property>
My entity classes are annotated to use caching
Changing the provider_class to org.hibernate.cache.EhCacheProvider doesn't help:Code:@Cache(usage=CacheConcurrencyStrategy.READ_ONLY)
So, how do I enable second level cache?Code:<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
Thanks, Steve


Reply With Quote
