<udpate id
= "方法名" parameter
= "java.util.List">
update `表名`
<trim prefix
= "set" suffixOverrides
= ",">
<trim prefix
= "字段1 = case" suffix
= "end,">
<foreach collection
="list" item
= "item" index
="index">
when ID
= #
{item
.ID
} then #
{item
.参数
1}
</foreach
>
</trim
>
<trim prefix
= "字段2 = case" suffix
= "end,">
<foreach collection
= "list" item
= "item" index
= "index">
when ID
= #
{item
.ID
} then #
{item
.参数
2}
</foreach
>
</trim
>
</trim
>
where
<foreach collection
= "list" separator
= "or" item
= "item" index
= "index">
ID
= #
{item
.ID
}
</foreach
>
</update
>
<update id
="方法名" parameterType
= "java.util.List">
<foreach collection
= "list" item
= "item" index
= "index" open
="begin" close
=";end;" separator
=";" >
UPDATE
'表'
<set>
<if test
= "item.参数1!=null and item.参数1 !=""toString()">
'对应表字段1' = #
{item
.参数
1}
</if>
<if test
= "item.参数2!=null and item.参数2 !="".toString()">
'对应表字段2' = #
{item
.参数
2}
</if>
</set
>
where id
= #
{item
.id
}
</foreach
>
</update
>
转载请注明原文地址: https://lol.8miu.com/read-78.html