UserMapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qianfeng.mapper.UserMapper">
<insert id="addUsers" parameterType="user">
INSERT INTO user (user_name,create_time) values
<foreach collection="list" item="user" separator=",">
(#{user.userName},#{user.createTime})
</foreach>
</insert>
<insert id="addUsers2" parameterType="user">
INSERT INTO user (user_name,create_time) values
<foreach collection="users" item="user" separator=",">
(#{user.userName},#{user.createTime})
</foreach>
</insert>
<delete id="deleteUsers">
DELETE FROM user where user_id IN
<foreach collection="list" item="userId" open="(" close=")" separator=",">
#{userId}
</foreach>
</delete>
<select id="selectUsersById" resultType="user">
SELECT *FROM user where user_id IN
<foreach collection="list" item="userId" open="(" close=")" separator=",">
#{userId}
</foreach>
</select>
<update id="updateUsers" parameterType="user">
<foreach collection="list" item="user" separator=";">
UPDATE user
<set>
<if test="user.userName!=null">user_name=#{user.userName},</if>
<if test="user.createTime!=null">create_time=#{user.createTime}</if>
</set>
<where>
user_id=#{user.userId}
</where>
</foreach>
</update>
</mapper>