-->
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: Want to associate two objects with same session
PostPosted: Mon Aug 01, 2005 10:54 am 
Newbie

Joined: Mon Aug 01, 2005 9:58 am
Posts: 3
Hi,
I am working on an complex object graph in a detached session.
I need to associate already saved object more than once in this graph because of multiple user interaction. So evertime i get a new from database with different java identity but same database identity. Now i want to save this object graph by opening a new session . In this case it gives UniqueObject exception, object with same identifier is already attached with the session.

How can i save this object graph. Any pointers will be helpful

Regards
Mukesh

Hibernate version : 2.1.4


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 01, 2005 11:50 am 
Regular
Regular

Joined: Wed Jan 07, 2004 5:16 pm
Posts: 65
Location: CA, USA
I'm not sure what you are trying to do, but you can't have more than one instance in the same session representing the same row in the database.

If you retrieve the same row multiple times in the same session you do not get multiple instances - Hibernate will return you the same object.

Can you explain more clearly what you are trying to acheive? Examples may help.


Kevin Hooke


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 02, 2005 12:30 am 
Newbie

Joined: Mon Aug 01, 2005 9:58 am
Posts: 3
Hi,
Suppose I have an object hierarchy A- B - C -D where A is top level Object. The process of attaching some already saved auxillary object happens in multiple user interaction. The Object is saved on save event at the end of this interaction where we fire fire save on Object A so the whole hierarchy gets saved.

Suppose i have already saved object X attached to B. If i try to attach the same object to D.

A-B-C-D
| |
X X

Since this happens in different interaction i have no clue that X is already attched to A. So i fetch a new object of X and attach it to D.
I cannot even reove mapping of X in A as X can be already saved object or new Object
Hope this clarifies the problem.

Note: In this case hibernate session does not span multiple user interaction i.e. for each hibernate call we open & close the session


Regards
Mukesh


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.