标签:
<insert id="add" parameterType="vo.Category">
<selectKey resultType="java.lang.Short" order="BEFORE" keyProperty="id">
SELECT SEQ_TEST.NEXTVAL FROM DUAL
</selectKey>
insert into category (name_zh, parent_id,
show_order, delete_status, description
)
values (#{nameZh,jdbcType=VARCHAR},
#{parentId,jdbcType=SMALLINT},
#{showOrder,jdbcType=SMALLINT},
#{deleteStatus,jdbcType=BIT},
#{description,jdbcType=VARCHAR}
)
</insert>
<insert id="add" parameterType="vo.Category" useGeneratedKeys="true" keyProperty="id">
insert into category (name_zh, parent_id,
show_order, delete_status, description
)
values (#{nameZh,jdbcType=VARCHAR},
#{parentId,jdbcType=SMALLINT},
#{showOrder,jdbcType=SMALLINT},
#{deleteStatus,jdbcType=BIT},
#{description,jdbcType=VARCHAR}
)
</insert>
或者<insert id="add" parameterType="vo.Category">
<selectKey resultType="java.lang.Short" order="AFTER" keyProperty="id">
SELECT LAST_INSERT_ID() AS id
</selectKey>
insert into category (name_zh, parent_id,
show_order, delete_status, description
)
values (#{nameZh,jdbcType=VARCHAR},
#{parentId,jdbcType=SMALLINT},
#{showOrder,jdbcType=SMALLINT},
#{deleteStatus,jdbcType=BIT},
#{description,jdbcType=VARCHAR}
)
</insert>
标签:
原文地址:http://www.cnblogs.com/dashuai01/p/4397165.html