码迷,mamicode.com
首页 > 数据库 > 详细

mybatis mysql 批量插入

时间:2017-10-20 16:04:09      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:collect   数据   mysq   mysql数据库   index   into   描述   size   效率   

场景描述:

  使用mybatis操作mysql数据库,进行批量插入数据,提高代码质量和执行效率。

环境:

  mybatis  spring  mysql  java  

xml配置文件

<insert id ="batchInsert" parameterType="java.util.List" >
        insert into table
        (column1,column2,column3)
        values
        <foreach collection ="list" item="item" index= "index" separator =",">
            (
            <if test="item.param1 != ‘‘ || item.param1 != null">
                #{item.param1},
            </if>
            <if test="item.param2 != ‘‘ and item.param2 != null">
                #{item.param2},
            </if>
            <if test="item.param3 != ‘‘ and item.param3 != null">
                #{item.param3}
            </if>
            )
        </foreach >
</insert >

 

  

mybatis mysql 批量插入

标签:collect   数据   mysq   mysql数据库   index   into   描述   size   效率   

原文地址:http://www.cnblogs.com/wkcn/p/7699518.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!