ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Justin Stanczak" <rizen...@gmail.com>
Subject MySQL LAST_INSERT_ID selectKey?
Date Wed, 02 Jan 2008 22:54:41 GMT
I'm currently using this to return the inserted objects generated key. These
are auto increment columns and I was wondering if this is correct. I notice
if I put the selectKey before the insert it returns the wrong key, is this
correct? Just wanted to verify.

<insert id="insertRole" parameterClass="Role">
  INSERT INTO SAVVYLMS.SVV_ROLE (SVV_NAME,SVV_TYPE_ID,SVV_DESC) VALUES
(#name#,#type#,#description#);
  <selectKey keyProperty="id" resultClass="long">
  SELECT LAST_INSERT_ID();
  </selectKey>
  </insert>

-- 
"All that is necessary for the triumph of evil is that good men do nothing."
  Edmund Burke

Mime
View raw message