-->
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: Instance uniqueness between sessions
PostPosted: Thu Jul 01, 2004 2:25 pm 
Newbie

Joined: Wed Jun 30, 2004 6:09 am
Posts: 2
Location: Paris, France
Hi,

I have a one to many relationship between 2 entities, let's say company and employee.

Let's say that in the database, there are 2 employees E1 and E2 sharing the same company C (id = 1).

I first load E1 and its company C1 (id = 1). I have E1.getCompany() = C1.

Then, I load E2 and I want to get its company also. My problem is that hibernate instanciates another instance of company : C2, with the same id (C1.id == C2.id) but, still, this is a different instance.

Is there any way to make it so that hibernate links E2 to the actual instance of company that was previously loaded ? That is to say C1 ?

I hope I am being clear here.

Tx.

_________________
Thomas Salomon
eComposite
www.ecomposite.fr


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 01, 2004 2:33 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Object identity is only guaranteed in session scope, and it is not possible to change that.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 01, 2004 3:46 pm 
Beginner
Beginner

Joined: Mon Jun 07, 2004 4:21 pm
Posts: 44
Location: Boston
This is a nice presentation on identities - worth taking a look:

http://hibernate.org/~gavin/pdoi.pdf


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.