码迷,mamicode.com
首页 > 其他好文 > 详细

mybatis xml中常见配置demo

时间:2015-08-08 11:58:39      阅读:107      评论:0      收藏:0      [点我收藏+]

标签:

更新

  1.

 <update id="updateByPrimaryKeySelective" parameterType="map" >
    update BS_STAFF_STATUS
    <set >
      <if test="status != null" >
        STATUS = #{status,jdbcType=VARCHAR},
      </if>
      <if test="enterTime != null" >
        ENTER_TIME = #{enterTime,jdbcType=TIMESTAMP},
      </if>
      <if test="insertTime != null" >
        INSERT_TIME = #{insertTime,jdbcType=TIMESTAMP},
      </if>
      <if test="deptId != null" >
        DEPT_ID = #{deptId,jdbcType=VARCHAR},
      </if>
      <if test="phoneNo != null" >
        PHONE_NO = #{phoneNo,jdbcType=VARCHAR},
      </if>
    </set>
    where STAFF_ID = #{staffId,jdbcType=VARCHAR}
  </update>

 查询

  1.

  

<select id="selectSelective" resultType="map" parameterType="map" >
    select 
    <include refid="Base_Column_List" />
    from BS_QUESTION_TRACE_INFO a
    <trim prefix="WHERE" prefixOverrides="AND |OR ">  
        <if test="questionId != null" >
            and QUESTION_ID = #{questionId,jdbcType=CHAR} 
          </if>
          <if test="preStatus != null">  
            and PRE_STATUS = #{preStatus,jdbcType=CHAR}  
        </if>
        <if test="curStatus != null">  
            and CUR_STATUS = #{curStatus,jdbcType=CHAR}  
        </if>
        <if test="oprType != null">  
            and OPR_TYPE = #{oprType,jdbcType=CHAR}  
        </if>
        <if test="questionOwnerId != null">
            and QUESTION_OWNER_ID = #{questionOwnerId,jdbcType=CHAR}  
        </if>
    </trim> 
  </select>

 

  

mybatis xml中常见配置demo

标签:

原文地址:http://www.cnblogs.com/a198720/p/4712760.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!