批量插入删除

public void deleteImageUrlList(List<ProductImageUrlDTO> list);

public void saveImageUrlList(List<ProductImageUrlDTO> list);

<insert id="saveImageUrlList" parameterType="java.util.List">
insert into t_product_color_img_mapping(product_color,product_color_url)
values
<foreach collection="list" item="item" index="index" open=""
close="" separator=",">
(
<if test="item.color != null">
product_color = #{item.color,jdbcType=VERCHAR},
</if>
<if test="item.imageUrl != null">
product_color_url = #{item.imageUrl,jdbcType=VERCHAR}
</if>
</foreach>
)
</insert>

<delete id="deleteImageUrlList" parameterType="java.util.List">
delete from t_product_color_img_mapping where
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item.product_id,jdbctype=INTEGER}
</foreach>
</delete>

原文地址:https://www.cnblogs.com/panxuejun/p/7501135.html