批量查询
<select id="listStudent" resultType="Student">
SELECT <include refid="Base_Column_List"/>
FROM student
WHERE id IN
<foreach collection="list" open"(" close=")" separator="," index="item">
#{item}
</foreach>
</select>
批量插入
<insert id="insertStudent" parameterType="List" keyProperty="Id" useGeneratedKeys="true"
keyColumn="id">
INSERT INTO student
(id,name,sex,address)
VALUES
<foreach collection="list" index="index" item="item" open="" close="" separator=",">
( #{item.id},#{item.name},#{item.sex},#{item.address})
</foreach>
</insert>
keyProperty=“Id”(主键) useGeneratedKeys=“true” keyColumn=“id” (主键)
写这个可以返回主键id
批量更新
<update id="updateStudent">
UPDATE
student
SET
del_flag = 1
WHERE id IN
<foreach collection="list" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</update>
批量删除
<delete id="deleteStudent" parameterType="List">
DELETE FROM student
WHERE id IN
<foreach collection="list" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreacn>
</delete>