ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Larry Meadors" <lmead...@apache.org>
Subject Re: Deleting a row in the childtable
Date Thu, 24 Aug 2006 15:43:21 GMT
The simple answer is "You don't - there is not an 'iBATIS way' to do this."

You can however do a couple of things.

In your database, you can define cascading deletes, so that when you
delete a parent, you delete the children, too.

You can also (on some databases) execute multiple statements in one
mapped statement. For example using Oracle, you could do this:

<delete id="delete">
 BEGIN
  DELETE FROM Child WHERE parentId=#parentId#;
  DELETE FROM Parent WHERE parentId=#parentId#;
 END;
</delete>

Larry

PS: I just noticed that this is the CS list, not the java list - that
mapped statement is from an example I had using the Java syntax, which
iirc, is the same, but if not...sorry. ;-)


On 8/24/06, Vani <vani.cl@tcs.com> wrote:
>
> Hi all,
>
> I have a parent table eg Department(DeptID,DeptName) and a childtable eg
> Employee(EmpId, EmpName,DeptID). Now my problem is, I want to delete a row
> in the child table if its corresponding foreign key(Dept ID) is deleted in
> the parent table. How do i implement it using Ibatis?
>
> Please help me.
>
> Thank you.
> --
> View this message in context: http://www.nabble.com/Deleting-a-row-in-the-childtable-tf2158879.html#a5964724
> Sent from the iBATIS - User - Cs forum at Nabble.com.
>
>

Mime
View raw message