版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
MyBatis的批量更新:
第一种写法:
<update id="batchUpdatePushStatus">
update test_paper
set push_status = #{pushStatus,jdbcType=INTEGER}
where paper_id in
<foreach collection="list" item="item" index="index" separator="," open="(" close=")">
#{item.paperId,jdbcType=INTEGER}
</foreach>
</update>
第二种写法:
<update id="batchUpdatePushStatus">
update test_paper
set push_status =
<foreach collection="list" item="item" index="index"
separator=" " open="case ID" close="end">
when #{item.paperId} then #{item.push_status }
</foreach>
where paper_id in
<foreach collection="list" item="item" index="index" separator="," open="(" close=")">
#{item.paperId,jdbcType=INTEGER}
</foreach>
</update>