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.  [ 9 posts ] 
Author Message
 Post subject: Can I configure Hibernate NOT to use any second level cache?
PostPosted: Wed Dec 08, 2004 11:43 am 
Beginner
Beginner

Joined: Wed Dec 08, 2004 9:17 am
Posts: 25
The net.sf.hibernate.cfg.Environment doc reads that JCS is assumed for 2nd level caching (though the readme in the distribution says "deprecated").
So I am questioning myself if I can configure hibernate not to use any 2nd level cache or if I have to call "evict()" on all objects that are not served by a cascading "evict()"?
Any help would be greatly appreciated.
Thanks a lot!

Oliver


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 08, 2004 11:44 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Read the chapter in the reference documentation about Caching.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 08, 2004 11:55 am 
Beginner
Beginner

Joined: Wed Dec 08, 2004 9:17 am
Posts: 25
Hi Christian,

already did that. The only extra info that I get is that EHCache replaced JCS as the default cache.
So, if there is a default cache that implies that 2nd level caching is "on". Excuse me, if I am too blind to find the part about switching it "off".
Do I interpret your answer correctly that there is no way to configure hibernate NOT to use 2nd level caching?

Thanks,

Oliver


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 08, 2004 11:56 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
If you don't add any cache tags to your mappings, nothing is cached.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 08, 2004 11:58 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
you have nothing to do.
if you don't configure second level caching at class level, no cache will be used.

read the chapter again
Quote:
It is possible to configure a cluster or JVM-level (SessionFactory-level) cache on a class-by-class and collection-by-collection basis

Code:
<cache
    usage="transactional|read-write|nonstrict-read-write|read-only"  (1)
/>


that is to say: if you don't do this, no cache will be used...

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 08, 2004 12:00 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
oups, Michael is faster

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 08, 2004 12:14 pm 
Beginner
Beginner

Joined: Wed Dec 08, 2004 9:17 am
Posts: 25
Thank you guys for the prompt answers!

I am comparing a possible hibernate data access layer against our current JDO data access layer. We have the requirement, that most of the time our persistent object graphs are managed by a persistence manager that uses 2nd level caching but in certain situations object graphs containing objects of the same classes have to be processed by a cacheless persistence manager. In JDO we just use a different persistence manager factory. It seems that with hibernate I can only switch caching on and off using the mappings. Since there is only one mapping per class it seems not possible for example to switch from a "cacheful" session factory to a "cacheless" factory. Objects are always cached or not cached, I can only supress caching by calling "evict()". Did I get it right, this time? ;-)

Cheers,

Oliver


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 08, 2004 12:21 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You can have two SessionFactories with a cache/cacheless configuration. Usually you don't put the <cache> elements in your mapping files, but bundle them in your hibernate.cfg.xml for all classes and associations. Which is nice, because one hibernate.cfg.xml is for one SessionFactory.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 08, 2004 12:23 pm 
Beginner
Beginner

Joined: Wed Dec 08, 2004 9:17 am
Posts: 25
Ahhh, perfect! Will try it out right away...

Thanks a lot!

Oliver


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