-->
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: Update key to null before delete
PostPosted: Tue Sep 06, 2005 2:30 pm 
Contributor
Contributor

Joined: Thu Jun 23, 2005 1:08 pm
Posts: 32
Location: Baltimore, MD
When I delete an object (let's call it "Person") it cascade deletes all the child objects (let's call them "Order"s). This is correct. However BEFORE it deletes them it set's the Order.Person field to null. this is how my database schema works, it is not a nullable column.

Examples:

session.Delete(somePerson);
session.Flush();

this does a:

UPDATE Order SET Person = NULL WHERE Person = 1235415
DELETE FROM Order WHERE Id = 12455;
...etc.

It's the first update that is bothering me. Anyone know of a mapping that prevents this?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 07, 2005 10:27 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Have you tried playing with inverse attribute? By the way, this got me thinking... it should be rather easy to alter NH code so that if during Flush an UPDATE is followed by a DELETE, the UPDATE is ignored.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 07, 2005 1:08 pm 
Contributor
Contributor

Joined: Thu Jun 23, 2005 1:08 pm
Posts: 32
Location: Baltimore, MD
I did play with it, but also with different cascade settings. Now, with cascade="all-delete-orphan" and inverse="true" it seems ot not do the update.

I'll test more thoroughly and post something more conclusive.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 23, 2005 2:18 pm 
Newbie

Joined: Tue Oct 11, 2005 8:02 am
Posts: 6
I have the same problem. It's strange it's working with inverse="true" because I don't have a bidirectional relationship.

It's quite cruical issue - I hope anybody has an explanation for this behaviour or fix if it's a bug?


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.