-->
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.  [ 4 posts ] 
Author Message
 Post subject: Object identity and detached object
PostPosted: Tue Apr 04, 2006 6:07 am 
Newbie

Joined: Mon Nov 21, 2005 9:57 am
Posts: 4
I'm a bit unsure of the discussion about object identity in the book Hibernate in Action (pg. 119).

While it is understood that hibernate guarantees that two references to the same in memory object for the same identifier value are equal (in terms of address equality), but if I have a reference to a detached object, say, to record A, and I call load(SomeClass.class, "A") in a new transaction, will the latter equals to the earlier if I reattach the earlier detached object to the transaction? Does hibernate guarantees reference equivalence in this case?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 04, 2006 7:55 am 
Senior
Senior

Joined: Tue Aug 23, 2005 8:52 am
Posts: 181
If you are doing the second transaction in the *same session*, then its guaranteed to be the same object. Otherwise it would be different


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 04, 2006 9:28 am 
Newbie

Joined: Mon Nov 21, 2005 9:57 am
Posts: 4
rajasaur wrote:
Otherwise it would be different


In that case, hibernate can no longer guarantee that there's only one instance for a particular row - unlike EJB, there could be more than one instances referring to the same row which are equivalent (by values) but not identical (address). Am I correct?

Thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 04, 2006 10:48 am 
Senior
Senior

Joined: Tue Aug 23, 2005 8:52 am
Posts: 181
bu66le wrote:
rajasaur wrote:
Otherwise it would be different


In that case, hibernate can no longer guarantee that there's only one instance for a particular row - unlike EJB, there could be more than one instances referring to the same row which are equivalent (by values) but not identical (address). Am I correct?

Thank you.

Yes, there could be multiple instances but in multiple sessions. Hibernate guarantees that there will be one object in a session. If you are worried about multiple sessions having records and trying to write over one-anohter, you probably need to look at one of the Optimistic concurrency strategies indicated at
http://www.hibernate.org/hib_docs/v3/re ... optimistic


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