<insert id="insertBatch" parameterType="java.util.List">
<foreach collection="datas" item="item" separator=";" open="begin" close=";end;">
insert into tablename
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="item.city_name != null">item.city_name,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="item.city_name != null">#{item.city_name},</if>
</trim>
</foreach>
</insert>
插入注意:separator=";" open="begin" close=";end;" 这三个参数
<delete id="deleteBatch" parameterType="java.util.List">
delete from tableName where
<foreach collection="datas" item="item" separator="or">
(user_code=#{item.user_code} and meter_code = #{item.meter_code})
</foreach>
</delete>
删除注意: separator="or"
<foreach collection="datas" item="item" index="index" open="" close="" separator=";">
update prt_monitor_bird
<set>
<if test="item.name != null and item.name != ''">name = #{item.name},</if>
</set>
where id = #{item.id}
</foreach>
更新注意 separator=";"