File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes iBatis, AS400: generated primary key value in code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "iBatis, AS400: generated primary key value in code" Watch "iBatis, AS400: generated primary key value in code" New topic
Author

iBatis, AS400: generated primary key value in code

Imre Tokai
Ranch Hand

Joined: Jun 04, 2008
Posts: 130
Hello!

i'm using DB2, AS400 database.

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?

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

Hope to get answer soon!


Regards
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: iBatis, AS400: generated primary key value in code
 
Similar Threads
insert command of iBatis SqlMapClient
Production deployment of iBatis - Examples ?
downloading file from jsr 168 application
OutOfMemoryError while Retrieving data
iBatis in Action: Can I persist my POJOs with it?