-->
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: Cascade delete problem
PostPosted: Thu Nov 06, 2008 8:50 am 
Newbie

Joined: Thu Nov 06, 2008 8:39 am
Posts: 2
I have domain object "Parent". It has propery - a collection of objects "Child"
here is piece of parent.hbm.xml
Code:
<set name="Children" lazy="true" access="field.camelcase" inverse="true" cascade="delete" batch-size="10" >
  <key column="[parent_id]" foreign-key="[FK_Children]" />
  <one-to-many class="ParentChild" />
</set>

There is also table "ParentChild" which has two columns <parent_id><child_id> where listed children of each parent

Problem is - when i delete parents, their children also deleted, but records from "ParentChild" (acording to deleted parent) remains unmodified

how can solve this problem?


Top
 Profile  
 
 Post subject: fk
PostPosted: Thu Nov 06, 2008 3:18 pm 
Newbie

Joined: Fri Oct 24, 2008 4:37 am
Posts: 11
Location: Planet earth
cant you just create a database constraint withh cascade delete? What kind'o database are you using?

_________________
With respect,
Morten


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 06, 2008 4:02 pm 
Newbie

Joined: Thu Nov 06, 2008 8:39 am
Posts: 2
ms sql 2005
is't it possible to solve my problem using only nhibernate mapping files?


Top
 Profile  
 
 Post subject: dont know 100%
PostPosted: Thu Nov 06, 2008 4:17 pm 
Newbie

Joined: Fri Oct 24, 2008 4:37 am
Posts: 11
Location: Planet earth
pretty new in this, but if I was in any lead of a project like nhibernate, I would not care about those only relation tables, I would expect the rdbms to handle this.

_________________
With respect,
Morten


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.