-->
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.  [ 6 posts ] 
Author Message
 Post subject: how can close second-level cache in hibernate3.0
PostPosted: Sat Apr 02, 2005 3:17 am 
Newbie

Joined: Sun Feb 27, 2005 5:00 am
Posts: 6
Location: shanghai, china
second-level cache is enabled by default, how can close it?

Thanks for your help!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 05, 2005 1:07 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Second level cache is not used by default unless you declare explicitly some caching in your hbm.xml files (or in the cfg.xml through <class-cahe/> and <collection-cache/>)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 05, 2005 7:20 pm 
Newbie

Joined: Fri Apr 01, 2005 1:03 am
Posts: 12
In Hibernate 3.0 final, I have noticed an issue trying to disable the second level cache. It seems I can't disable it and the dependency on ehcache without setting the Cache Provider to something (i.e. - HashtableCacheProvider).

In Configuration.java, line 182, from Hibernate 3.0 release:
Code:
// Second-level / query cache:
      
      settings.setCacheProvider( createCacheProvider(properties) );
      
      boolean useSecondLevelCache = PropertiesHelper.getBoolean(Environment.USE_SECOND_LEVEL_CACHE, properties, true);
      log.info( "Second-level cache: " + enabledDisabled(useSecondLevelCache) );
      settings.setSecondLevelCacheEnabled(useSecondLevelCache);


There is an attempt to instantiate the Cache Provider [createCacheProvider()] before it is checked whether the cache is enabled or not. If no cache provider is set, it attempts to instantiate EhCacheProvider by default.

Thus, if you just set hibernate.cache.use_second_level_cache to false, without setting the cache provider, you get a class not found exception for one of the ehcache classes.

Is this how it is supposed to work? I would think you could flip the logic above to remove the dependency on ehcache.

I noticed mention of a org.hibernate.cache.EmptyCacheProvider class in the distribution hibernate.properties, but that it is not included in the distribution.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 06, 2005 4:30 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
That's correct we prepare the provider, but we don't use it. Is it really a big issue?
You can set the HashCache provider, if you don't want any dependency, but DON'T use it

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 06, 2005 4:44 pm 
Newbie

Joined: Fri Apr 01, 2005 1:03 am
Posts: 12
It's not a big issue code wise ... It just seems counter intuitive.

Say for instance I said you have to specify an LDAP provider in a system where you had LDAP disabled... does that make sense?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 06, 2005 7:02 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
This is was "misfeature" ;)

It'll be fixed.


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