1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
| <?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.course.dao.UserMapper"> <resultMap id="BaseResultMap" type="com.course.vo.UserVo"> <id column="id" jdbcType="INTEGER" property="id" /> <result column="name" jdbcType="VARCHAR" property="name" /> <result column="age" jdbcType="INTEGER" property="age" /> <result column="address" jdbcType="VARCHAR" property="address" /> <result column="hire_date" jdbcType="TIMESTAMP" property="hireDate" /> </resultMap> <sql id="Base_Column_List"> id, name, age, address, hire_date </sql> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> select <include refid="Base_Column_List" /> from user where id = #{id,jdbcType=INTEGER} </select> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> delete from user where id = #{id,jdbcType=INTEGER} </delete> <insert id="insert" parameterType="com.course.vo.UserVo"> insert into user (id, name, age, address, hire_date) values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{age,jdbcType=INTEGER}, #{address,jdbcType=VARCHAR}, #{hireDate,jdbcType=TIMESTAMP}) </insert> <insert id="insertSelective" parameterType="com.course.vo.UserVo"> insert into user <trim prefix="(" suffix=")" suffixOverrides=","> <if test="id != null"> id, </if> <if test="name != null"> name, </if> <if test="age != null"> age, </if> <if test="address != null"> address, </if> <if test="hireDate != null"> hire_date, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null"> #{id,jdbcType=INTEGER}, </if> <if test="name != null"> #{name,jdbcType=VARCHAR}, </if> <if test="age != null"> #{age,jdbcType=INTEGER}, </if> <if test="address != null"> #{address,jdbcType=VARCHAR}, </if> <if test="hireDate != null"> #{hireDate,jdbcType=TIMESTAMP}, </if> </trim> </insert> <update id="updateByPrimaryKeySelective" parameterType="com.course.vo.UserVo"> update user <set> <if test="name != null"> name = #{name,jdbcType=VARCHAR}, </if> <if test="age != null"> age = #{age,jdbcType=INTEGER}, </if> <if test="address != null"> address = #{address,jdbcType=VARCHAR}, </if> <if test="hireDate != null"> hire_date = #{hireDate,jdbcType=TIMESTAMP}, </if> </set> where id = #{id,jdbcType=INTEGER} </update> <update id="updateByPrimaryKey" parameterType="com.course.vo.UserVo"> update user set name = #{name,jdbcType=VARCHAR}, age = #{age,jdbcType=INTEGER}, address = #{address,jdbcType=VARCHAR}, hire_date = #{hireDate,jdbcType=TIMESTAMP} where id = #{id,jdbcType=INTEGER} </update> <select id="getAllUser" resultMap="BaseResultMap"> select <include refid="Base_Column_List" /> from user </select> <select id="getUserByVo" parameterType="com.course.vo.UserVo" resultMap="BaseResultMap"> select <include refid="Base_Column_List" /> from user </select> </mapper>
|