<?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.liquidnet.service.sequence.mapper.SysSequenceMapper" >
  <resultMap id="BaseResultMap" type="com.liquidnet.service.sequence.entity.SysSequence" >
    <id column="seq_name" property="seqName" jdbcType="VARCHAR" />
    <result column="current_val" property="currentVal" jdbcType="BIGINT" />
    <result column="increment" property="increment" jdbcType="INTEGER" />
  </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" >
    seq_name, current_val, increment
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.liquidnet.service.sequence.entity.SysSequenceExample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    from sys_sequence
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select
    <include refid="Base_Column_List" />
    from sys_sequence
    where seq_name = #{seqName,jdbcType=VARCHAR}
  </select>
  <insert id="insert" parameterType="com.liquidnet.service.sequence.entity.SysSequence" >
    insert into sys_sequence (seq_name, current_val, increment
      )
    values (#{seqName,jdbcType=VARCHAR}, #{currentVal,jdbcType=BIGINT}, #{increment,jdbcType=INTEGER}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.liquidnet.service.sequence.entity.SysSequence" >
    insert into sys_sequence
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="seqName != null" >
        seq_name,
      </if>
      <if test="currentVal != null" >
        current_val,
      </if>
      <if test="increment != null" >
        increment,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="seqName != null" >
        #{seqName,jdbcType=VARCHAR},
      </if>
      <if test="currentVal != null" >
        #{currentVal,jdbcType=BIGINT},
      </if>
      <if test="increment != null" >
        #{increment,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.liquidnet.service.sequence.entity.SysSequenceExample" resultType="java.lang.Integer" >
    select count(*) from sys_sequence
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    update sys_sequence
    <set >
      <if test="record.seqName != null" >
        seq_name = #{record.seqName,jdbcType=VARCHAR},
      </if>
      <if test="record.currentVal != null" >
        current_val = #{record.currentVal,jdbcType=BIGINT},
      </if>
      <if test="record.increment != null" >
        increment = #{record.increment,jdbcType=INTEGER},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map" >
    update sys_sequence
    set seq_name = #{record.seqName,jdbcType=VARCHAR},
      current_val = #{record.currentVal,jdbcType=BIGINT},
      increment = #{record.increment,jdbcType=INTEGER}
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.liquidnet.service.sequence.entity.SysSequence" >
    update sys_sequence
    <set >
      <if test="currentVal != null" >
        current_val = #{currentVal,jdbcType=BIGINT},
      </if>
      <if test="increment != null" >
        increment = #{increment,jdbcType=INTEGER},
      </if>
    </set>
    where seq_name = #{seqName,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.liquidnet.service.sequence.entity.SysSequence" >
    update sys_sequence
    set current_val = #{currentVal,jdbcType=BIGINT},
      increment = #{increment,jdbcType=INTEGER}
    where seq_name = #{seqName,jdbcType=VARCHAR}
  </update>


    <select id="generateSeqNo" resultType="java.lang.Long">
        select _nextval(#{sequenceName,jdbcType=VARCHAR})
    </select>
</mapper>
