• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

iBatis, AS400: generated primary key value in code

 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic