<insert id="answer_insert" parameterClass="Answer">
<selectKey resultClass="java.lang.Integer" type="pre"
keyProperty="id">
select SEQ_TMG_ID.nextval val from dual
</selectKey>
<![CDATA[
INSERT INTO Answer
(
id,login_id,question_id)
VALUES (#id#,#login_id#,#question_id)
]]>
<selectKey resultClass="int" keyProperty="id">
SELECT
S_SGS_REMARK.CURRVAL AS ID FROM DUAL
</selectKey>
</insert>
在java程序中只需要使用
return Integer.parseInt(this.getSqlMapClientTemplate().insert("user.insert",user).toString());
即可将插入对象的id返回。