- 插入
<insert id="batchSave" > insert into table_name (`name`,age) values <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> #{item.name, jdbcType=VARCHAR}, #{item.age, jdbcType=INTEGER} </foreach> </insert>
- 更新
<update id="updateNameBatch"> update user <trim prefix="set" suffixOverrides=","> <trim prefix="name =case" suffix="end,"> <foreach collection="list" item="i" index="index"> when id=#{i.id} then #{i.name} </foreach> </trim> gmt_modify = now() </trim> where <foreach collection="list" item="i" index="index" separator="or"> (id=#{i.id}) </foreach> </update>