-->
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: Session cache vs. 2nd level cache
PostPosted: Tue May 16, 2006 4:41 am 
Newbie

Joined: Tue May 16, 2006 3:46 am
Posts: 3
It seems that the session cache does not store an instance but all the persistent properties of the instance. So modifications of a transient property are lost.
In my case, associations gestion is implemented manually, so a child entity is a transient property of its father. The only solution is to use an instance cache instead of the session cache ?
Thx.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 16, 2006 5:31 am 
Regular
Regular

Joined: Wed Aug 25, 2004 6:23 am
Posts: 91
I think it's exactly the other way around to that - the session (also called first-level) cache stores references to objects so that if you load the same object twice by key in two different queries or calls to session.load, session.get etc you will get two references to the same object. This means that:-

Code:
PersistentClass a = session.load(23, PersistentClass.class);
PersistentClass b = session.load(23, PersistentClass.class);
return a==b;


should return true. The second level cache just stores persistend property values, so that an object that isn't in the first level cache can be loaded without hitting the database. The session level cache is (as its name implies) scoped to a session, so

Code:
PersistentClass a = session.load(23, PersistentClass.class);
session = sessionFactory.openSession();
PersistentClass b = session.load(23, PersistentClass.class);
return a==b;


will return false. Is this what you are seeing?


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 18, 2006 4:46 am 
Newbie

Joined: Tue May 16, 2006 3:46 am
Posts: 3
I did more tests, I agree with you about the session cache and the second level cache.
Thx!


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.