运维开发网

Mybatis在执行insert语句返回自增主键

运维开发网 https://www.qedev.com 2020-03-12 15:08 出处:51CTO 作者:沙漏半杯
<insert id="add" parameterType="student"> <selectKey resultType="java.lang.Short" order="AFTER" keyProperty="id"> SELECT LAST_INSERT_ID() AS id </selectKey>

<insert id="add" parameterType="student">

<selectKey resultType="java.lang.Short" order="AFTER" keyProperty="id">

SELECT LAST_INSERT_ID() AS id

</selectKey>

               或者(

               <selectKey resultType="java.lang.Short" order="BEFORE" keyProperty="id">

SELECT SEQ_TEST.NEXTVAL FROM DUAL

</selectKey>)

insert into category (name_zh, parent_id,

)

values (#{nameZh,jdbcType=VARCHAR},

#{parentId,jdbcType=SMALLINT},

)

0

精彩评论

暂无评论...
验证码 换一张
取 消