mapper:
int updateAddress(@Param("list") List<Address> list);
xml:
<update id="updateAddress2"> update org_address t <trim prefix="set" suffixOverrides=","> <trim prefix="t.province_id = case" suffix="end,"> <foreach collection="list" item="item" index="index"> <if test="item.provinceId != null"> when t.address_id=#{item.addressId} then #{item.provinceId} </if> </foreach> </trim> <trim prefix="t.province_name = case" suffix="end,"> <foreach collection="list" item="item" index="index"> <if test="item.provinceName != null"> when t.address_id=#{item.addressId} then #{item.provinceName} </if> </foreach> </trim> <trim prefix="t.city_id = case" suffix="end,"> <foreach collection="list" item="item" index="index"> <if test="item.cityId != null"> when t.address_id=#{item.addressId} then #{item.cityId} </if> </foreach> </trim> </trim> ,t.country_id = '86',t.country_name = '中国' where t.address_id in <foreach collection="list" item="item" index="index" open="(" separator="," close=")"> #{item.addressId} </foreach> </update>