-->
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.  [ 6 posts ] 
Author Message
 Post subject: collection manipulation
PostPosted: Wed Mar 03, 2004 8:09 pm 
Pro
Pro

Joined: Mon Sep 08, 2003 4:30 pm
Posts: 203
Hi All,

If I have a one to many from object A to object B, but A does _not_ control the lifecycle of B, which is the proper way to implement the mapping and the java code for adding/removing B elements to/from A?

I am particulary having problems for removing a B from the collection referenced by A.

If I do A.getB().remove(objB) it will not change anything only if the B is mapped with delete-orphan, but then the B would be deleted from the DB which is not desirable.

Please advice,

--steve p.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 03, 2004 9:28 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Is it a bidir ?
Just do b.setA(null);
and remove delete-orphan

Not a bidir ?
Read http://www.hibernate.org/155.html, you've probably misunderstood the inverse="true" usage

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 03, 2004 9:46 pm 
Pro
Pro

Joined: Mon Sep 08, 2003 4:30 pm
Posts: 203
Quote:
Not a bidir ?
Read http://www.hibernate.org/155.html, you've probably misunderstood the inverse="true" usage


It's not a bidir. I read the article but couldn't find an example for my case. Please advice on how to solve my problem if it is _not_ a bidir.

Thanks really much,

--steve p.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 03, 2004 9:47 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Then
inverse="false"
cascade="save-update" or "none"
a.getBs().remove(objB);

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 03, 2004 9:49 pm 
Pro
Pro

Joined: Mon Sep 08, 2003 4:30 pm
Posts: 203
Thank you for the prompt reply!

Best regards.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 03, 2004 10:05 pm 
Pro
Pro

Joined: Mon Sep 08, 2003 4:30 pm
Posts: 203
emmanuel wrote:
Then
inverse="false"
cascade="save-update" or "none"
a.getBs().remove(objB);


One more question, please:

If I do

a.getBs().clear()

will this clear all references from A to B?

'Cause I believe it didn't work when I tried it.

thx [again].


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