mybatis mysql批量增改

插入 

void insertThemes(@Param("insertInputMapList") List<Map<String, String>> insertInputMapList);

Map<String, String>其实和theme的对象是一样的,没有任何区别

<insert id="insertThemes">
    insert into
    theme(themeJstId,themeName)
    values
    <foreach collection="insertInputMapList" index="index" 
         item="item" separator=",">
     (#{item.themeJstId},#{item.themeName}))
    </foreach>
</insert>

 

更改

void updateThemes(@Param("updateInputMapList") List<Map<String, String>> updateInputMapList);

在appliacation.properties里面得在连接url的时候加上allowMultiQueries=true

<update id="updateThemes">
    <foreach collection="updateInputMapList" index="index"
        item="item" separator=";">
        update theme
        set themeName = #{item.themeName}            
        where themeJstId = #{item.themeJstId}
    </foreach>
</update>
原文地址:https://www.cnblogs.com/CuiHongYu/p/10601565.html