mybatis批量插入、删除

//把Group对象装在List中然后进行如下操作
<insert id="addGroup" parameterType="java.util.List">
		insert into group(group_id,a_id,b_id)
		values
		<foreach collection="list" index="index" separator="," item="itm">
			(#{itm.GroupId},#{itm.AId},#{itm.BId})
		</foreach>
	</insert>


	<delete id="removeGroup" parameterType="java.util.Map">
		delete from group
		<where>
			<if test="group_id!=null"> group_id = #{group_id} and</if>
			<choose>
				<otherwise>group_id is null and</otherwise>
			</choose>
		</where>
		a_id in
		<foreach collection="list" index="index" open="(" close=")"
			separator="," item="itm">
			#{itm}
		</foreach>
	</delete>

你可能感兴趣的:(mybatis批量插入、删除)