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

<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},

)

你可能感兴趣的:(mybatis,insert操作返回自增主键)