-->
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.  [ 2 posts ] 
Author Message
 Post subject: How to delete parent when child is deleted?
PostPosted: Thu Nov 11, 2004 7:09 am 
Newbie

Joined: Fri Aug 13, 2004 6:38 am
Posts: 4
Hibernate version: 2.1.6

In Hibernate one can have cascading operations *from parent to children* (some entity manages its lists, sets, maps or other child entites).

We have a mapping file "Schedule.hbm.xml" where every Schedule is bound to House, Flat and so on:
...
<many-to-one name="house" class="House" column="house_id" not-null="false" cascade="none"/>
...

In this relation the parent is Schedule and children are House, Flat etc.

This relation (from Schedule to other entites) is not cascading:
When a Schedule is deleted, Houses, Flats and other entites which were referenced from Schedule will not be deleted. Only the Schedule will be deleted.

But we need another kind of cascading:
When a House or Flat etc. is being deleted, all Schedules which have a link to this House or Flat must be deleted as well.

So we are looking for an elegant way to do this. Didnt find anything in the Docs though so I hope someone can help me ehre!
Thanks in advacne
MVeeck


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 12, 2004 4:11 am 
Regular
Regular

Joined: Fri Nov 12, 2004 12:07 am
Posts: 57
Location: Beijing,China
correct your error,Shedule are children and House is parent.


Parent's mapping xml is following:

....
....
<set cascade="all">
<key column="Schedule foreign key"/>
...
</set>


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