-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: How to enable Second Level Cache
PostPosted: Thu May 24, 2007 1:03 am 
Beginner
Beginner

Joined: Tue May 08, 2007 1:20 pm
Posts: 24
Any pointers/suggestions on how to enable second level cache in Hibernate will be highly appreciated
We are using technology stack of JSF Spring Hibernate

Regards
Bansi


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 24, 2007 1:54 am 
Senior
Senior

Joined: Thu May 17, 2007 2:31 am
Posts: 194
Location: Sri Lanka
Hi

Code:
<hibernate-configuration>
   <session-factory>
      ...
      <property name="hibernate.cache.provider_class">
         org.hibernate.cache.EHCacheProvider
      </property>
      ...
   </session-factory>
</hibernate-configuration>


You can set "hibernate.cache.provider_class" to different CashProviders.


And

Use <cache usage="read-only"/> or other usage in mapping files


Amila

(Don't forget to rate if helps)


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 24, 2007 9:40 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Read the manual.
See http://www.hibernate.org/hib_docs/v3/reference/en/html/performance.html#performance-cache


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 26, 2007 1:58 pm 
Beginner
Beginner

Joined: Tue May 08, 2007 1:20 pm
Posts: 24
Thanks David/amila

I have read the docs & also setup the second level cache
But the problem is i am not able to get it to work.

Here is the configuration from applicationContext-Hibernate.xml

Code:

<property name="hibernateProperties">         
         <props>         
         
         <prop key="hibernate.cache.use_second_level_cache">true</prop>
         <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
         <prop key="hibernate.cache.use_query_cache">true</prop>
         
         
         <prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
          <prop key="hibernate.cglib.use_reflection_optimizer">true</prop>         
         </props>         
      </property>      


From the Log i get a message second level cache enabled
Code:
2007-06-26 10:48:27,876 INFO [org.hibernate.cfg.SettingsFactory] - <Second-level cache: enabled>
2007-06-26 10:48:27,876 INFO [org.hibernate.cfg.SettingsFactory] - <Query cache: enabled>
2007-06-26 10:48:27,876 INFO [org.hibernate.cfg.SettingsFactory] - <Cache provider: org.hibernate.cache.EhCacheProvider>
2007-06-26 10:48:27,907 INFO [org.hibernate.cfg.SettingsFactory] - <Optimize cache for minimal puts: disabled>
2007-06-26 10:48:27,907 INFO [org.hibernate.cfg.SettingsFactory] - <Structured second-level cache entries: disabled>
2007-06-26 10:48:27,907 INFO [org.hibernate.cfg.SettingsFactory] - <Query cache factory: org.hibernate.cache.StandardQueryCacheFactory>


Now the problem is , i have created a file by name ehcache.xml under src directory for query cache as follows
Code:
<cache name="query.allCDs"
........
.........
........
/>

It gives the following error
Code:

net.sf.ehcache.CacheException: Error configuring from file:/C:/apache-tomcat-5.5.17/webapps/namsNG/WEB-INF/classes/ehcache.xml. Initial cause was Error configuring from input stream. Initial cause was null:6: Element <cache> does not allow attribute "name".



Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.