-->
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.  [ 5 posts ] 
Author Message
 Post subject: Problem in cascade="all-delete-cascade"
PostPosted: Thu Oct 05, 2006 11:03 am 
Beginner
Beginner

Joined: Fri Aug 12, 2005 7:05 am
Posts: 25
Location: TamilNadu
cascade="all-delete-orphan"
when i am using this property in set for delete child records,hibernate first execute update query for child table to update foriegnkey to null and then delete parent record and then delete child records.

But in my case foriegn key in child table is not null field, so i am getting FK constraint error while tring to update null to FK.

Note : Hibernate first tring to delete parent record and then delete child records, for this reason only it first update FK to null in child table.This is happening when we set cascade="all-delete-orphan".

Is this problem in Hibernate?

I dont want to explicitly delete child records.

any ideas or alternates...


Thanks in advance



Hibernate version:
3.1

Name and version of the database you are using:

Oracle 9i

The generated SQL (show_sql=true):


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 06, 2006 2:37 am 
Regular
Regular

Joined: Tue May 16, 2006 3:32 am
Posts: 117
Have you set inverse="true" for your Set ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 06, 2006 9:55 am 
Beginner
Beginner

Joined: Fri Aug 12, 2005 7:05 am
Posts: 25
Location: TamilNadu
Hi JeyeshJ,

Thanx for your response.

If i use inverse="true" in set then got error like
records------>org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update

bcz hibernate tring to delete parent record first and then tring to delete child records..but as per DB FK constraint we can't do like this.

any other way to do this?


Regards
Shanmugam.N


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 06, 2006 9:56 am 
Beginner
Beginner

Joined: Fri Aug 12, 2005 7:05 am
Posts: 25
Location: TamilNadu
Hi JeyeshJ,

Thanx for your response.

If i use inverse="true" in set then got error like
records------>org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update

bcz hibernate tring to delete parent record first (without set null to FK in child table) and then tring to delete child records..but as per DB FK constraint we can't do like this.

any other way to do this?


Regards
Shanmugam.N


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 09, 2006 1:54 am 
Regular
Regular

Joined: Tue May 16, 2006 3:32 am
Posts: 117
This works correctly. Check your mapping files and code.


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