mybatis 批量更新
摘抄自:https://blog.csdn.net/LQQianLee/article/details/79771618
二、批量更新——单条件
-
<update id="update" parameterType="java.util.List">
-
update nt_menu
-
<trim prefix="set" suffixOverrides=",">
-
<trim prefix="breakfast =case" suffix="end,">
-
<foreach collection="list" item="cus">
-
<if test="cus.breakfast != null">
-
when menuId=#{cus.menuId} then #{cus.breakfast}
-
</if>
-
</foreach>
-
</trim>
-
<trim prefix="lunch =case" suffix="end,">
-
<foreach collection="list" item="cus">
-
<if test="cus.lunch != null">
-
when menuId=#{cus.menuId} then #{cus.lunch}
-
</if>
-
</foreach>
-
</trim>
-
<trim prefix="dinner =case" suffix="end,">
-
<foreach collection="list" item="cus">
-
<if test="cus.dinner != null">
-
when menuId=#{cus.menuId} then #{cus.dinner}
-
</if>
-
</foreach>
-
</trim>
-
<trim prefix="modifier =case" suffix="end,">
-
<foreach collection="list" item="cus">
-
<if test="cus.modifier != null">
-
when menuId=#{cus.menuId} then #{cus.modifier}
-
</if>
-
</foreach>
-
</trim>
-
</trim>
-
<where>
-
<foreach collection="list" separator="or" item="cus">
-
menuId=#{cus.menuId}
-
</foreach>
-
</where>
-
</update>
批量更新——多条件
如果有来生,要做一片树叶。
春天恋上枝,炎夏恋上水。
深秋恋上土,东来化作泥。
润物细无声,生生世世恋红尘。