以下为临时记录的
1.修改数据库url:添加allowMultiQueries=true
2.Test.java
name,age,sex,status
3.dao
int insertBaches(@Param("testList") List<Test> matchingList,@Param("type") int type);
4.mapper.xml
INSERT ignore INTO tbl_test
(name,age) VALUES
<foreach collection="testList" item="item" separator=",">
(
#{item.name,jdbcType=INTEGER},
#{item.age,jdbcType=INTEGER}
)
</foreach>
<if test="type !=null and type==1">
ON DUPLICATE KEY UPDATE `status` = if(`status`=-1,0,`status`),sex = if(sex=0,1,0);
</if>
1.修改数据库url:添加allowMultiQueries=true
2.Test.java
name,age,sex,status
3.dao
int insertBaches(@Param("testList") List<Test> matchingList,@Param("type") int type);
4.mapper.xml
INSERT ignore INTO tbl_test
(name,age) VALUES
<foreach collection="testList" item="item" separator=",">
(
#{item.name,jdbcType=INTEGER},
#{item.age,jdbcType=INTEGER}
)
</foreach>
<if test="type !=null and type==1">
ON DUPLICATE KEY UPDATE `status` = if(`status`=-1,0,`status`),sex = if(sex=0,1,0);
</if>