-->
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.  [ 1 post ] 
Author Message
 Post subject: breaking parent-child by deleting a child
PostPosted: Fri Aug 24, 2007 12:07 pm 
Newbie

Joined: Tue Dec 12, 2006 3:27 pm
Posts: 2
Hi there,

Given the following relationship:

public class A
{
private Set tags; // a set of Tag
...
}

public class Tag {... }

and the mapping:

<class name="A" ... >

<set name="tags" table="A_TAG_XREF">
<key column="A_ID" not-null="true"/>
<many-to-many class="Tag" column="TAG_ID" not-found="ignore"/>
</set>

</class>

By default, if some Tag is contained in some A.tags, that Tag can't be deleted because of a foreign key constraint.

I'd like to be able to delete an instance of Tag and have it automatically removed from all associations in which it participates:

Tag t = ...
session.delete(t); // remove from all A.tags sets.

this would translate in SQL to:

delete from A_TAG_XREF where TAG_ID=<the id of the tag>
delete from tag_table where TAG_ID=<the id of the tag>

Is there any option that would implement this sort of semantics? Or I should manually remove an object from all its associations before deleting it?

Thanks a lot in advance!
Boris


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.