<?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.zheng.upms.dao.mapper.UpmsUserOrganizationMapper">
  <resultMap id="BaseResultMap" type="com.zheng.upms.dao.model.UpmsUserOrganization">
    <id column="user_organization_id" jdbcType="INTEGER" property="userOrganizationId" />
    <result column="user_id" jdbcType="INTEGER" property="userId" />
    <result column="organization_id" jdbcType="INTEGER" property="organizationId" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <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 close=")" collection="criterion.value" item="listItem" open="(" 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="(" prefixOverrides="and" suffix=")">
            <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 close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    user_organization_id, user_id, organization_id
  </sql>
  <select id="selectByExample" parameterType="com.zheng.upms.dao.model.UpmsUserOrganizationExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from upms_user_organization
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
    <if test="limit != null">
      <if test="offset != null">
        limit ${offset}, ${limit}
      </if>
      <if test="offset == null">
        limit ${limit}
      </if>
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from upms_user_organization
    where user_organization_id = #{userOrganizationId,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from upms_user_organization
    where user_organization_id = #{userOrganizationId,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.zheng.upms.dao.model.UpmsUserOrganizationExample">
    delete from upms_user_organization
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.zheng.upms.dao.model.UpmsUserOrganization">
    insert into upms_user_organization (user_organization_id, user_id, organization_id
      )
    values (#{userOrganizationId,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{organizationId,jdbcType=INTEGER}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.zheng.upms.dao.model.UpmsUserOrganization">
    insert into upms_user_organization
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="userOrganizationId != null">
        user_organization_id,
      </if>
      <if test="userId != null">
        user_id,
      </if>
      <if test="organizationId != null">
        organization_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="userOrganizationId != null">
        #{userOrganizationId,jdbcType=INTEGER},
      </if>
      <if test="userId != null">
        #{userId,jdbcType=INTEGER},
      </if>
      <if test="organizationId != null">
        #{organizationId,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.zheng.upms.dao.model.UpmsUserOrganizationExample" resultType="java.lang.Long">
    select count(*) from upms_user_organization
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update upms_user_organization
    <set>
      <if test="record.userOrganizationId != null">
        user_organization_id = #{record.userOrganizationId,jdbcType=INTEGER},
      </if>
      <if test="record.userId != null">
        user_id = #{record.userId,jdbcType=INTEGER},
      </if>
      <if test="record.organizationId != null">
        organization_id = #{record.organizationId,jdbcType=INTEGER},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update upms_user_organization
    set user_organization_id = #{record.userOrganizationId,jdbcType=INTEGER},
      user_id = #{record.userId,jdbcType=INTEGER},
      organization_id = #{record.organizationId,jdbcType=INTEGER}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.zheng.upms.dao.model.UpmsUserOrganization">
    update upms_user_organization
    <set>
      <if test="userId != null">
        user_id = #{userId,jdbcType=INTEGER},
      </if>
      <if test="organizationId != null">
        organization_id = #{organizationId,jdbcType=INTEGER},
      </if>
    </set>
    where user_organization_id = #{userOrganizationId,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.zheng.upms.dao.model.UpmsUserOrganization">
    update upms_user_organization
    set user_id = #{userId,jdbcType=INTEGER},
      organization_id = #{organizationId,jdbcType=INTEGER}
    where user_organization_id = #{userOrganizationId,jdbcType=INTEGER}
  </update>
  <cache type="org.mybatis.caches.ehcache.LoggingEhcache" />
</mapper>