mybatis批量插入和更新

批量插入

<insert id="add" parameterType="java.util.List">
insert all
<foreach item="item" index="index" collection="list" open="" separator="" close="">
into PARAMETETER_CONFIGURATION
( INPUT_NAME, WEIGTH_,MONTH_,ACTUAL_WORK)
values (#{item.inputName,jdbcType=DECIMAL},#{item.weigth,jdbcType=VARCHAR}, #{item.month,jdbcType=VARCHAR},#{item.actualWork,jdbcType=VARCHAR})
</foreach>
select 1 from dual
</insert>

批量更新

<!--批量更新 -->
<update id="batchUpdate" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" open="begin" close=";end;" separator=";">
UPDATE S_APPOINT
<set>
<if test="item.quitReasonNew != null and item.quitReasonNew!='' ">
QUIT_REASONNEW = #{item.quitReasonNew,jdbcType=VARCHAR},
</if>
<if test="item.quitTypeNew != null and item.quitTypeNew !='' ">
QUIT_TYPENEW = #{item.quitTypeNew,jdbcType=VARCHAR},
</if>
</set>
where APPOINT_NUMBER = #{item.appointNumber,jdbcType=VARCHAR}
</foreach>
</update>

posted @ 2019-11-22 21:51  w'c's  阅读(277)  评论(0编辑  收藏  举报