首页 > 数据库技术 > 详细

mybatis mysql 批量插入

时间:2017-10-20 15:22:19      阅读:206      评论:0      收藏:0      [点我收藏+]

场景描述:

  使用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 批量插入

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!