1. 配置文件中一定要添加 allowMultiQueries=true 的作用:
1.可以在sql语句后携带分号,实现多语句执行。
2.可以执行批处理,同时发出多个SQL语句。
2. 动态SQL语句列子:
<insert id="insertSellVipPersonList" parameterType="java.util.List">
<foreach collection="list" item="item">
INSERT INTO sell_vip_person
(
<trim suffixOverrides=",">
<if test="item.shopId!=null">
shop_id,
</if>
<if test="item.paymentId!=null">
payment_id,
</if>
<if test="item.billType!=null">
bill_type,
</if>
<if test="item.sell1!=null">
sell1,
</if>
<if test="item.sellJobNum!=null">
sell_job_num,
</if>
<if test="item.sellName!=null">
sell_name,
</if>
<if test="item.sell1Dept!=null">
sell1_dept,
</if>
<if test="item.sell1KpiRatio!=null">
sell1_kpi_ratio,
</if>
<if test="item.createAt!=null">
create_at,
</if>
<if test="item.updateAt!=null">
update_at
</if>
</trim>
)
VALUES
(
<trim suffixOverrides=",">
<if test="item.shopId!=null">
#{item.shopId},
</if>
<if test="item.paymentId!=null">
#{item.paymentId},
</if>
<if test="item.billType!=null">
#{item.billType},
</if>
<if test="item.sell1!=null">
#{item.sell1},
</if>
<if test="item.sellJobNum!=null">
#{item.sellJobNum},
</if>
<if test="item.sellName!=null">
#{item.sellName},
</if>
<if test="item.sell1Dept!=null">
#{item.sell1Dept},
</if>
<if test="item.sell1KpiRatio!=null">
#{item.sell1KpiRatio},
</if>
<if test="item.createAt!=null">
#{item.createAt},
</if>
<if test="item.updateAt!=null">
#{item.updateAt}
</if>
</trim>
);
</foreach>
</insert>