ibatis insert之后返回主键

1.配置文件

    <insert id="testInsert" parameterClass="xx">
            <selectKey resultClass="int" keyProperty="id">
               select seq_for_xx.Nextval from dual
            </selectKey>

            INSERT INTO xx(ID,ACCOUNTID,OSTEMPLATEID,VCPU,MEMORY,VMONAME,VMNUMBER,TAGS,PASSWORD,PREFIX,STARTDATE,ENDDATE,TZINDEX,SUBMITTIME,APPROVEDTIME,OS,STATE)
             VALUES(#id#,..)
    </insert>

2.java代码

   Integer id = (Integer)sqlMapClientTemplate.insert("xx", xx);

你可能感兴趣的:(ibatis)