ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guido García Bernardo <ggb...@tid.es>
Subject Re: handle auto_increment insert into mysql
Date Wed, 16 Nov 2005 15:08:55 GMT
Your problem has been discussed previously on this list 
(http://www.mail-archive.com/user-java@ibatis.apache.org/msg01752.html)

Use the <selectKey ...> tag.

<insert id="insertFolder" parameterClass="folder">
  INSERT INTO folder (parent_id, owner, foldername)
  VALUES (#parentId#, #owner#, #foldername#)
  <selectKey resultClass="int" keyProperty="folderId">
    SELECT LAST_INSERT_ID() AS folderId
  </selectKey>
</insert>

Good luck,

Scott Purcell wrote:

>Hello,
>
>I am trying to get the hang of using IBATIS. In order to get my hands wet I am running
the reumann struts lesson. It is working, and I am trying to add some tables to the example,
to get a feel for the framework.
>
>But one of the tables has an "auto_increment" (mysql) on it. So when I do an insert, I
am unsure how to handle this. Could someone lead me to where I find information on handling
that?
>
>Thanks,
>Scott
>                                                
>
- 
Guido García Bernardo - ggarciab@itdeusto.com
Tfn. +34 983 54 89 08
ITDEUSTO - Valladolid (Spain)


Mime
View raw message