mybatis mysql 批量插入
阿新 • • 發佈:2017-10-20
column mysq logs 提高 span pri into XML 進行
場景描述:
使用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 批量插入