-->
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: Removing bi-directional relationships with session.update
PostPosted: Fri Feb 13, 2004 2:29 pm 
Newbie

Joined: Tue Aug 26, 2003 12:31 pm
Posts: 14
I am working in an environment where we will need to load an object from Hibernate and pass it to a Web layer where a user can update the object. We will update the object and reassociate the object back to a new session and save the object. This works as the documentation describes.

However, we also have situations where we might have a bi-directional relationship between objects that might need to be updated. Imagine you have an interface that has checkboxes where the user can select and deselect options. Now the user deselects one of the checkboxes which relates to one of the objects in the collection (which is stored in a higher part of the object graph). When the parent object is reassociated back to the session and update is invoked on the parent, none of the removed elements from the collection are removed from the table.

I do not want to use session.delete to permanently remove the objects. I just want to break the relationship. I also understand how to do this manually with bi-directional relationships by dereferencing both ends of the relationship. Can this be done automatically with session.update/saveOrUpdate?

Thanks,

Mark[/img]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 13, 2004 2:39 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I don't think so

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 13, 2004 2:43 pm 
Newbie

Joined: Tue Aug 26, 2003 12:31 pm
Posts: 14
So are you saying that I have to let updates that Hibernate can handle happen and then update my collections that changed seperately in the same method or another method after the update manually?

Thanks,

Mark


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 13, 2004 2:57 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
If I reformulate your needs
You want to partially update an object graph having bidir by updating half of the association and expect Hibernate to correctly reattach it.
And my answer is you can't do it automatically.

_________________
Emmanuel


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.