mybatis List 批量 insert 对象
<insert id="addTrainRecordBatch">
insert into product_sort (sell_id, shop_id,
sort_id, fid, name,
status, lev
)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{item.sellId},#{item.shopId},#{item.sortId},#{item.fid},#{item.name},#{item.status},#{item.lev})
</foreach>
</insert>
上述collection的值为list对象,对应的Mapper是这样的
public void addBath(List<ProductSort> listProductSort);
扫描二维码关注公众号,回复:
530718 查看本文章