-->
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.  [ 3 posts ] 
Author Message
 Post subject: child not deleted after cascade delete parent?
PostPosted: Sun Oct 12, 2003 10:18 am 
Newbie

Joined: Sat Oct 11, 2003 11:24 pm
Posts: 7
parent:
Code:
<set name="children" lazy="true" inverse="true" cascade="delete">
...


child:
Code:
<many-to-one name="parent" class="Parent"/>


operation:
Code:
session.delete(parentObject);
session.flush();


After session.delete(), record in parent table is deleted, but the child record is still there...why?

hibernate generated sql:
Code:
Hibernate: delete from Parent where id=?

none of child delete script generated

Schema export:
Code:
alter table Child add index (parent), add constraint FK36A178A2F6669636 foreign key (parent) references Parent (id);


using MySQL 4, Hibernate 2.0.3


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 12, 2003 10:19 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Because you have a bug somwhere in your code (the part you didn't show).

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 12, 2003 10:49 am 
Newbie

Joined: Sat Oct 11, 2003 11:24 pm
Posts: 7
It's my fault, I forgot load Parent object to session...sorry!


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