Mybatis 批量更新
学习资源:https://blog.csdn.net/xyjawq1/article/details/74129316
<!-- 批量更新模板 -->
<update id="updateBatch" parameterType="java.util.List">
update bc_product_combo
<trim prefix="set" suffixOverrides=",">
<trim prefix="user_id =case" suffix="end,">
<foreach collection="list" item="item" index="index">
<if test="item.userId != null" >
when id=#{item.id} then #{item.userId,jdbcType=CHAR}
</if>
</foreach>
</trim>
<trim prefix="user_name =case" suffix="end,">
<foreach collection="list" item="item" index="index">
<if test="item.userName != null" >
when id=#{item.id} then #{item.userName,jdbcType=VARCHAR}
</if>
</foreach>
</trim>
</trim>
<where>
id in
<foreach collection="list" index="index" item="item" separator="," open="(" close=")">
#{item.id,jdbcType=CHAR}
</foreach>
</where>
</update>