直接上项目中的代码xml:
<update id="batchUpdateRecord" parameterType="list">
update request_record
<trim prefix="set" suffixOverrides=",">
<trim prefix="track_nums = case" suffix="end,">
<foreach collection="list" item="i" index="index">
<if test="i.trackNums!=null and i.trackNums!= ''">
when request_record_id=#{i.requestRecordId} then #{i.trackNums}
if>
foreach>
trim>
<trim prefix="response_status = case" suffix="end,">
<foreach collection="list" item="i" index="index">
<if test="i.responseStatus!=null and i.responseStatus!= ''">
when request_record_id=#{i.requestRecordId} then #{i.responseStatus}
if>
foreach>
trim>
trim>
where
<foreach collection="list" separator="or" item="i" index="index" >
request_record_id=#{i.requestRecordId}
foreach>
update>
dao:
void batchUpdateSitfRequestRecord(List<Map<String, String>> records);