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
| <?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.test.redis.mapper.UserMapper"> <resultMap id="BaseResultMap" type="com.test.redis.vo.User"> <id column="id" jdbcType="INTEGER" property="id"/> <result column="name" jdbcType="VARCHAR" property="name"/> <result column="age" jdbcType="INTEGER" property="age"/> </resultMap>
<sql id="Base_Column_List"> id, `name`, age </sql>
<select id="getUserById" parameterType="java.lang.Integer" resultMap="BaseResultMap"> select <include refid="Base_Column_List"/> from user where id = #{id,jdbcType=INTEGER} </select>
<delete id="deleteUserById" parameterType="java.lang.Integer"> delete from user where id = #{id,jdbcType=INTEGER} </delete>
<insert id="insertUser" keyColumn="id" keyProperty="id" parameterType="com.test.redis.vo.User" useGeneratedKeys="true"> insert into user (`name`, age) values (#{name,jdbcType=VARCHAR}, #{age,jdbcType=INTEGER}) </insert>
<update id="updateUser" parameterType="com.test.redis.vo.User"> update user <set> <if test="name != null"> `name` = #{name,jdbcType=VARCHAR}, </if> <if test="age != null"> age = #{age,jdbcType=INTEGER}, </if> </set> where id = #{id,jdbcType=INTEGER} </update>
<select id="queryAllUser" resultMap="BaseResultMap"> select <include refid="Base_Column_List"/> from user </select> </mapper>
|