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.