ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron H <be.spec...@gmail.com>
Subject how to retrieve the keyProperty in useGeneratedKeys
Date Sat, 14 Nov 2009 19:22:07 GMT

hi!

i have this code to insert a usercase:

<insert id="insertUserCase" parameterType="watchabbits.vo.UserCase"
keyProperty="id" useGeneratedKeys="true">
		insert into usercase(gender,age)
		values(#{gender},#{age});
	</insert>

how can i retrieve the id?
i wrote this code:
public Integer saveUserCase(UserCase theCase){
		int userCaseId =0;
		SqlSession session = sqlMapper.openSession();
		try {
			userCaseId =
session.insert("watchabbits.ibatis.UserCaseMapper.insertUserCase", theCase);
			
		} finally {
			session.close();
		}
		return userCaseId;
	}
but i don't get the id..


-- 
View this message in context: http://old.nabble.com/how-to-retrieve-the-keyProperty-in-useGeneratedKeys-tp26353033p26353033.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Mime
View raw message