批量插入:
<insert id="insertBatch" parameterType="java.util.List">
insert into order_promotion_details (pmt_id, promotion_name, promotion_fee,
promotion_desc, promotion_id, gift_item_id,
gift_item_name, gift_item_num, pmt_type,
update_time, create_time)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{item.pmtId,jdbcType=VARCHAR}, #{item.promotionName,jdbcType=VARCHAR}, #{item.promotionFee,jdbcType=REAL},
#{item.promotionDesc,jdbcType=VARCHAR}, #{item.promotionId,jdbcType=VARCHAR}, #{item.giftItemId,jdbcType=VARCHAR},
#{item.giftItemName,jdbcType=VARCHAR}, #{item.giftItemNum,jdbcType=INTEGER}, #{item.pmtType,jdbcType=VARCHAR},
#{item.updateTime,jdbcType=TIMESTAMP}, #{item.createTime,jdbcType=TIMESTAMP})
</foreach>
</insert>
批量更新:
<update id="updateBatch" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" separator=";" >
UPDATE order_source
SET
lastmodify =#{item.lastmodify},
update_time=#{item.updateTime}
WHERE order_id=#{item.orderId}
</foreach>
</update>
批量插入的separator是逗号,批量更新的separator是分号;其他的没有太大区别