一、批量插入
1、Dao层
int insertStudentList(@Param("list") List<TStudent> student);
2、Mapper层
<insert id="insertStudentList" useGeneratedKeys="true" keyProperty="id">
insert into TStudent (name,age,myClass) values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.name,jdbcType=VARCHAR}, #{item.age,jdbcType=INTEGER}, #{item.myClass,jdbcType=VARCHAR})
</foreach>
</insert>
二、批量删除
1、Dao层
int deleteTStudentList(@Param("deleteIdLit") List<Integer> idList);
2、Mapper层
<delete id="deleteTStudentList">
delete from TStudent where id in
<foreach collection="deleteIdLit" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
三、批量更新
1、Dao层
int updateTest(@Param("list") List<TestTable> list);
2、Mapper层
<update id="updateTest">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
update TestTable set
is_anomaly=#{item.isAnomaly},is_check_complete=#{isCheckComplete},remark=#{remark},update_user=#{update_user} where id=#{item.id}
</foreach>
</update>