-->
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.  [ 2 posts ] 
Author Message
 Post subject: object instances and caching
PostPosted: Thu Mar 08, 2007 5:43 pm 
Newbie

Joined: Thu May 18, 2006 11:30 pm
Posts: 9
I'm wondering how multiple Java instances of the same db object affect Hibernate caching.

For example, suppose I retrieve an object A with the PK, but then make a copy B of it, update B (but don't touch the PK) and save B. Then I make another copy C of it, do some other update and save C. Will this affect the session-level caching, so that it behave differently from when the same object instance is used? i.e., is the session-level caching based on the PK or the object reference?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 09, 2007 8:12 am 
Regular
Regular

Joined: Fri May 12, 2006 4:05 am
Posts: 106
Hi,

Hibernate won't allow attaching an object to a session if the session-context already contains another object with the same identifier. So in your example you will get an exception thrown when trying to save B. This way hibernate gets around the question you're asking.


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