Mybatis -- 批量更新 -- updateBatch

mysql数据库配置:

数据库连接必须配置:&allowMultiQueries=true并且‘&’ 用&替换

jdbc.url=jdbc:mysql://192.168.10.10:3306/gt_environ?characterEncoding=utf8&connectTimeout=1000&allowMultiQueries=true

啦啦啦

---------------UpdateBatch

Class : Dao

    /**
     * 批量更新environ
     * 
     * @author Liang
     *
     * 2017年4月25日
     */
    void updateBatch(List<Environ> environs);

XML : 

    <update id="updateBatch" >
        <foreach collection="list" close="" index="index" item="item" open="" separator=";">
            UPDATE environ
            SET
                pm25_h = #{item.pm25H},
                pm10_h = #{item.pm10H},
                temp_h = #{item.tempH},
                humi_h = #{item.humiH},
                co2_h = #{item.co2H},
                tvoc_h = #{item.tvocH},
                conn_status = #{item.connStatus},
            update_time = NOW()
            WHERE id = #{item.id}
        </foreach>
    </update>

啦啦啦

-------

原文地址:https://www.cnblogs.com/ClassNotFoundException/p/6768443.html