-->
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: delete problem
PostPosted: Fri Nov 04, 2005 8:32 am 
Newbie

Joined: Wed Oct 12, 2005 5:35 am
Posts: 9
hi,

A category contains several items (one-to-many)
if I delete a item from the category (not cascade delete), it can be deleted from database
for example: session.delete(item);
the hibernate will generate a SQL as following
delete XXX from ..

but when I delete one item and update the category at the same time, hibernate alway generate two update SQL and set the foreign key of item to be null.
for example :
session.update(category);
session.delete(item);
the generated SQL is
update Category ...
update Item set category_id=null, ...

how can I solve this problem
thanks a lot


Top
 Profile  
 
 Post subject: Re: delete problem
PostPosted: Fri Nov 04, 2005 10:07 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
simonhuang wrote:
hi,

A category contains several items (one-to-many)
if I delete a item from the category (not cascade delete), it can be deleted from database
for example: session.delete(item);
the hibernate will generate a SQL as following
delete XXX from ..

but when I delete one item and update the category at the same time, hibernate alway generate two update SQL and set the foreign key of item to be null.
for example :
session.update(category);
session.delete(item);
the generated SQL is
update Category ...
update Item set category_id=null, ...

how can I solve this problem
thanks a lot


Does your Category contain a collection of items ? What does that mapping look like ? especially the inverse="" attribute.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


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.