ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rashid Jilani" <jil...@lifebiosystems.com>
Subject RE: reading an identity column and inserting it in to other table
Date Tue, 24 Feb 2009 14:42:11 GMT
Hi: Mario thanks for response. I am already doing exactly what you have
told, and it is working, but I was looking to do every thing in 1 call
instead of 2 calls.   

Right now I first call the statement inseretIntoUser, and then invoke other
call to store the id attribute returned by sqlmap.insert(). I thought there
must be more elegant way to do all this in 1 call?


-----Original Message-----
From: Mario Ds Briggs [mailto:mario.briggs@in.ibm.com] 
Sent: Monday, February 23, 2009 10:06 PM
To: user-java@ibatis.apache.org
Cc: user-java@ibatis.apache.org
Subject: Re: reading an identity column and inserting it in to other table

Aside to mysql identity semantics, in all cases iBatis will return the db
generated value as the return of the sqlmap.insert() call.

Additionally in your use case below, if the 'RegisteredUser'  object has a
'ID' attribute, ibatis will set it to the db generated value. You can also
control the attribute that ibatis will set the value into using
'keyProperty' of <selectkey>


             "Rashid Jilani"                                               
             stems.com>                                                 To 
             24/02/2009 01:53                                           cc 
             Please respond to         reading an identity column and      
             user-java@ibatis.         inserting it in to other table      

Hi: guys can some one shed some light how to read an identity column in
mysql and update the other table with the identity value.

E.g  <insert id="inseretIntoUser"
        INSERT INTO address(zip, country)
        VALUES(#address.zip#, #address.country#)
        <selectKey resultClass="int" >
            SELECT @@IDENTITY AS id

I am not sure how to read the value of id and use in a different insert


View raw message