I am trying to configure JBoss Cache 2 level using Hibernate version 3.3.1.GA, domain entities are configured using hibernate annotations 3.4.0.GA.
Here is the properties for AnnotationSessionFactoryBean
Code:
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.CacheProvider">org.hibernate.cache.jbc2.JBossCacheRegionFactory</prop>
Here is maven dependencies to add JBoss cache jars into the app classpath
Code:
<dependency>
<groupId>org.jboss.cache</groupId>
<artifactId>jbosscache-core</artifactId>
<version>3.2.1.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jbosscache2</artifactId>
<version>3.3.2.GA</version>
</dependency>
To test the second level cache I annotated the domain entity with
Code:
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
running the unit test throws
Code:
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.impl.NoCachingRegionFactory.buildEntityRegion(NoCachingRegionFactory.java:66)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:255)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1368)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAuto
Any help would be appreciated. thanks