UserRoleMapper.xml 6.7 KB
<?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.tianbo.mapper.UserRoleMapper" >
  <resultMap id="BaseResultMap" type="com.tianbo.model.UserRole" >
    <id column="ID" property="id" jdbcType="DECIMAL" />
    <result column="USER_ID" property="userId" jdbcType="DECIMAL" />
    <result column="ROLE_ID" property="roleId" jdbcType="DECIMAL" />
  </resultMap>
  <sql id="Example_Where_Clause" >
    <where >
      <foreach collection="oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <foreach collection="criteria.criteria" item="criterion" >
              <choose >
                <when test="criterion.noValue" >
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue" >
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue" >
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue" >
                  and ${criterion.condition}
                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause" >
    <where >
      <foreach collection="example.oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <foreach collection="criteria.criteria" item="criterion" >
              <choose >
                <when test="criterion.noValue" >
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue" >
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue" >
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue" >
                  and ${criterion.condition}
                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List" >
    ID, USER_ID, ROLE_ID
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.tianbo.model.UserRoleExample" >
    <include refid="OracleDialectPrefix" />
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    from USER_ROLE
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
    <include refid="OracleDialectSuffix" />
  </select>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.math.BigDecimal" >
    select 
    <include refid="Base_Column_List" />
    from USER_ROLE
    where ID = #{id,jdbcType=DECIMAL}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.math.BigDecimal" >
    delete from USER_ROLE
    where ID = #{id,jdbcType=DECIMAL}
  </delete>
  <delete id="deleteByExample" parameterType="com.tianbo.model.UserRoleExample" >
    delete from USER_ROLE
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.tianbo.model.UserRole" >
    insert into USER_ROLE (ID, USER_ID, ROLE_ID
      )
    values (#{id,jdbcType=DECIMAL}, #{userId,jdbcType=DECIMAL}, #{roleId,jdbcType=DECIMAL}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.tianbo.model.UserRole" >
    insert into USER_ROLE
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        ID,
      </if>
      <if test="userId != null" >
        USER_ID,
      </if>
      <if test="roleId != null" >
        ROLE_ID,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=DECIMAL},
      </if>
      <if test="userId != null" >
        #{userId,jdbcType=DECIMAL},
      </if>
      <if test="roleId != null" >
        #{roleId,jdbcType=DECIMAL},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.tianbo.model.UserRoleExample" resultType="java.lang.Integer" >
    select count(*) from USER_ROLE
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    update USER_ROLE
    <set >
      <if test="record.id != null" >
        ID = #{record.id,jdbcType=DECIMAL},
      </if>
      <if test="record.userId != null" >
        USER_ID = #{record.userId,jdbcType=DECIMAL},
      </if>
      <if test="record.roleId != null" >
        ROLE_ID = #{record.roleId,jdbcType=DECIMAL},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map" >
    update USER_ROLE
    set ID = #{record.id,jdbcType=DECIMAL},
      USER_ID = #{record.userId,jdbcType=DECIMAL},
      ROLE_ID = #{record.roleId,jdbcType=DECIMAL}
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.tianbo.model.UserRole" >
    update USER_ROLE
    <set >
      <if test="userId != null" >
        USER_ID = #{userId,jdbcType=DECIMAL},
      </if>
      <if test="roleId != null" >
        ROLE_ID = #{roleId,jdbcType=DECIMAL},
      </if>
    </set>
    where ID = #{id,jdbcType=DECIMAL}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.tianbo.model.UserRole" >
    update USER_ROLE
    set USER_ID = #{userId,jdbcType=DECIMAL},
      ROLE_ID = #{roleId,jdbcType=DECIMAL}
    where ID = #{id,jdbcType=DECIMAL}
  </update>
  <sql id="OracleDialectPrefix" >
    <if test="page != null" >
      select * from ( select row_.*, rownum rownum_ from ( 
    </if>
  </sql>
  <sql id="OracleDialectSuffix" >
    <if test="page != null" >
      <![CDATA[ ) row_ ) where rownum_ > #{page.begin} and rownum_ <= #{page.end} ]]>
    </if>
  </sql>
</mapper>