ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ingmar Lötzsch <iloetz...@asci-systemhaus.de>
Subject Re: Need help on Inserting child Object .
Date Mon, 09 Feb 2009 11:55:41 GMT
Hello Rahul,

> Well I could not understand what you actually mean to say by this
> 
> " This works only, if there are no depedencies to the child table and if you don't have
to log the changes "

This refers to the use of DELETE during the UPDATE only. If there is a
third table with

FOREIGN KEY (orderitemid)
REFERENCES orderitem(id)
ON DELETE RESTRICT (respectively CASCADE)

the

DELETE FROM orderitem
WHERE orderid = #value#

could cause a FOREIGN KEY violation respectively the deletion of some
rows in the third table. In your case this seems irrelevant.

>> sqlMapClient.delete("Order.deleteDetails", order);
> 
> This works only, if there are no depedencies to the child table and if
> you don't have to log the changes.
> 
>> for (int i=0;i<order.getOrderItems().size();i++) {
>> OrderItem oi = (OrderItem) order.getOrderItems().get(i);
>> oi.setOrderId(order.getOrderId());
>> sqlMapClient.insert("OrderItem.insert", oi);
>> }

Ingmar

Mime
View raw message