Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Second-level cache is not enabled for usage
PostPosted: Mon Feb 01, 2010 7:33 pm 
Newbie

Joined: Mon Feb 01, 2010 7:24 pm
Posts: 2
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


Top
 Profile  
 
 Post subject: Re: Second-level cache is not enabled for usage
PostPosted: Mon Feb 01, 2010 8:51 pm 
Newbie

Joined: Mon Feb 01, 2010 7:24 pm
Posts: 2
Ok I made some progress. Fixed the configuration problem AnnotationSessionFactoryBean
Code:
<prop key="hibernate.cache.provider_class">org.hibernate.cache.jbc2.JBossCacheRegionFactory</prop>


Now according to the documentation the provider class is implementation of CacheProvider. However JBossCacheRegionFactory does not implement CacheProvider. This is contrary to the Hibernate documentation. Where can I find doc to provide JBoss cache2 as second level cache?

thanks


Top
 Profile  
 
 Post subject: Re: Second-level cache is not enabled for usage
PostPosted: Wed Feb 03, 2010 6:20 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Here's a start:

http://community.jboss.org/wiki/jbosscache

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.