Mybatis批量插入或更新(基于唯一索引)
2019-01-29 本文已影响0人
Coderlifesunny
<insert id="batchInsertOrUpdate">
insert into supplier_quotation_goods (supplier_account, project_serial_number, goods_id, goods_name, quotation_price, quotation_quantity, status, created, modified, yn) VALUES
<foreach collection="list" item="record" separator=",">
(#{record.supplierAccount}, #{record.projectSerialNumber}, #{record.goodsId}, #{record.goodsName}, #{record.quotationPrice}, #{record.quotationQuantity}, 0, now(), now(), 1)
</foreach>
ON DUPLICATE KEY UPDATE
quotation_price=values(quotation_price),quotation_quantity=values(quotation_quantity),modified=now()
</insert>