-->
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.  [ 3 posts ] 
Author Message
 Post subject: basic second level cache questions
PostPosted: Tue Feb 28, 2006 6:41 am 
Newbie

Joined: Thu Apr 08, 2004 7:17 am
Posts: 10
Hi,

I need some basic informations on the way hibernate is interacting with the second level cache. I'm using hibernate 3.1.2 with oscache from the distribution.

Example:
I have 3 persistent classes A,B and C. Class A has a collection of B and a 1:1 relation to class C. The 2nd level cache settings for all classes and relations are read-write. Every class has its own 2nd level cache region.

Question 1:
When hibernate puts an instance of A to the 2nd level cache does it still have the filled collection of B's and the relation to C in the way of complete instances of B's and C or are the objects disconnected from A and put in there own 2nd level cache regions?

Question 2:
When 1:n or n:m relations are declared to be cached what is cached? Are the complete referenced objects cached? If the referencend class allready has its own 2nd level cache region is there a way to use this instead of creating a new 2nd level cache region for the relation?

It would be very kind if somebody can help me.

Tanks in advance.
Alex


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 28, 2006 5:38 pm 
Regular
Regular

Joined: Wed Feb 08, 2006 3:59 pm
Posts: 75
Objects are "dehydrated" before being stored in cache, meaning individual properties (including associations) are turned into serialized objects. When an object is loaded from cache, it is "rehydrated" into a regular POJO (or a proxy to it).
This way to concurrent sessions accessing the 'same' object are actually accessing two separate instances (both rehydrated from cache).

So question 1 : A is stored to cache, A's Bs are stored to their cache region, and so is C. A dehydrated state containts C's ID.

question 2 : if a 1-n or m-m is relation is cached, only the association is cached, not the objects themselves. So If A as many Bs and the A to B relation is cached, and if you the Bs have been expired from cache, calling A.getBs() will end up in one request for each individual B.

Disclaimer : I've not read not understood nor written Hibernate's whole code so I might be wrong. If a guru reads this and if I'm wrong, feel free to flame me :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 01, 2006 7:32 am 
Newbie

Joined: Thu Apr 08, 2004 7:17 am
Posts: 10
Tank you very much for your help.
I was hoping that the cache would behave this way.


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