<?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="mapper接口文件存放位置" > <resultMap id="BaseResultMap" type="实体类包位置" > <id column="id" property="id" jdbcType="BIGINT" /> <result column="gmt_create" property="gmtCreate" jdbcType="TIMESTAMP" /> <result column="gmt_modified" property="gmtModified" jdbcType="TIMESTAMP" /> <result column="user_name" property="userName" jdbcType="VARCHAR" /> </resultMap> <resultMap id="QueryResultMap" type="实体类包位置" extends="BaseResultMap" /> <sql id="Query_Where_Clause" > <trim prefix="WHERE" prefixOverrides="AND |OR " > <if test="id != null" > AND id = #{id,jdbcType=BIGINT} </if> <if test="gmtCreate != null" > AND gmt_create = #{gmtCreate,jdbcType=TIMESTAMP} </if> <if test="gmtModified != null" > AND gmt_modified = #{gmtModified,jdbcType=TIMESTAMP} </if> <if test="userName != null" > AND user_name = #{userName,jdbcType=VARCHAR} </if> </trim> </sql> <sql id="Update_By_Query_Where_Clause" > <trim prefix="WHERE" prefixOverrides="AND |OR " > <if test="query.id != null" > AND id = #{query.id,jdbcType=BIGINT} </if> <if test="query.gmtCreate != null" > AND gmt_create = #{query.gmtCreate,jdbcType=TIMESTAMP} </if> <if test="query.gmtModified != null" > AND gmt_modified = #{query.gmtModified,jdbcType=TIMESTAMP} </if> <if test="query.userName != null" > AND user_name = #{query.userName,jdbcType=VARCHAR} </if> </trim> </sql> <sql id="Base_Column_List" > id, gmt_create, gmt_modified, user_name </sql> <select id="selectByQuery" resultMap="BaseResultMap" parameterType="query势例类存放路径" > select <include refid="Base_Column_List" /> from user <if test="_parameter != null" > <include refid="Query_Where_Clause" /> </if> </select> <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" > select <include refid="Base_Column_List" /> from user where id = #{id,jdbcType=BIGINT} </select> <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" > delete from user where id = #{id,jdbcType=BIGINT} </delete> <delete id="deleteByQuery" parameterType="query势例类存放路径" > delete from user <if test="_parameter != null" > <include refid="Query_Where_Clause" /> </if> </delete> <insert id="insert" parameterType="实体类存放位置" > <selectKey resultType="java.lang.Long" keyProperty="id" order="AFTER" > SELECT @@IDENTITY </selectKey> insert into user (gmt_create, gmt_modified, user_name) values (#{gmtCreate,jdbcType=TIMESTAMP}, #{gmtModified,jdbcType=TIMESTAMP}, #{userName,jdbcType=VARCHAR}) </insert> <insert id="insertOrUpdate" parameterType="实体类存放位置" > <selectKey resultType="java.lang.Long" keyProperty="id" order="AFTER" > SELECT @@IDENTITY </selectKey> insert into user (gmt_create, gmt_modified, owner_uid, user_id, user_name, display_name, active ) values (#{gmtCreate,jdbcType=TIMESTAMP}, #{gmtModified,jdbcType=TIMESTAMP}, #{userName,jdbcType=VARCHAR}) ON DUPLICATE KEY UPDATE </insert> <select id="countByQuery" parameterType="实体类存放位置" resultType="java.lang.Integer" > select count(*) from user <if test="_parameter != null" > <include refid="Query_Where_Clause" /> </if> </select> <update id="updateByQuerySelective" parameterType="map" > update user <set > <if test="record.id != null" > id = #{record.id,jdbcType=BIGINT}, </if> <if test="record.gmtCreate != null" > gmt_create = #{record.gmtCreate,jdbcType=TIMESTAMP}, </if> <if test="record.gmtModified != null" > gmt_modified = #{record.gmtModified,jdbcType=TIMESTAMP}, </if> <if test="record.userName != null" > user_name = #{record.userName,jdbcType=VARCHAR}, </if> </set> <if test="_parameter != null" > <include refid="Update_By_Query_Where_Clause" /> </if> </update> <update id="updateByQuery" parameterType="map" > update user set id = #{record.id,jdbcType=BIGINT}, gmt_create = #{record.gmtCreate,jdbcType=TIMESTAMP}, gmt_modified = #{record.gmtModified,jdbcType=TIMESTAMP}, user_name = #{record.userName,jdbcType=VARCHAR}, <if test="_parameter != null" > <include refid="Update_By_Query_Where_Clause" /> </if> </update> <update id="updateByPrimaryKeySelective" parameterType="实体类包位置" > update user <set > <if test="gmtCreate != null" > gmt_create = #{gmtCreate,jdbcType=TIMESTAMP}, </if> <if test="gmtModified != null" > gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}, </if> <if test="userName != null" > user_name = #{userName,jdbcType=VARCHAR}, </if> </set> where id = #{id,jdbcType=BIGINT} </update> <update id="updateByPrimaryKey" parameterType="实体类包位置" > update user set gmt_create = #{gmtCreate,jdbcType=TIMESTAMP}, gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}, user_name = #{userName,jdbcType=VARCHAR}, </update> </mapper>