You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Tokajac <im...@hotmail.com> on 2008/09/21 18:19:13 UTC

Primary key value, generated by iBatis (or database), in code

Hello!

in User.xml i have: 
    <insert id="addUser" parameterClass="UserForm">    
	INSERT INTO USR (
	username, passwordfirstname, lastname, role
        )
    </insert>

in UserDao.java i have 
   sqlMapper.insert("addUser", user);

Primary key is generated by iBatis (or database). How can i get this value? 
For now, i'm using SELECT MAX(pKey) but it's not the happiest way for
solving this problem.

I found this example. 
http://ibatis.apache.org/docs/java/user/com/ibatis/sqlmap/client/SqlMapClient.html
How should i write the <insert> for making this work?


Regards

-- 
View this message in context: http://www.nabble.com/Primary-key-value%2C-generated-by-iBatis-%28or-database%29%2C-in-code-tp19595857p19595857.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: Primary key value, generated by iBatis (or database), in code

Posted by Tokajac <im...@hotmail.com>.
I forgot to write that i'm using DB2, AS400 database

I checked
http://opensource.atlassian.com/confluence/oss/pages/viewpage.action?pageId=407
but still no luck

Hope to get answer soon!


Regards
-- 
View this message in context: http://www.nabble.com/Primary-key-value%2C-generated-by-iBatis-%28or-database%29%2C-in-code-tp19595857p19596083.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.