MyBatis動態SQL使用,傳入參數Map中的Key判斷


當使用Map做為參數時,可以用_parameter.containsKey(變量名)來判斷map中是否包含有些變量:

  

<select id="selectRule" parameterType="Map" resultType="com.ourangel.weixin.domain.Rule">  
    SELECT ruleId,msgType,event,respId,reqValue,firstRespId,createDate,yn  
    FROM oal_tb_rule  
    WHERE yn = 1  
    <if test="_parameter.containsKey('msgType')">  
        AND msgType = #{msgType,jdbcType=VARCHAR})  
    </if>  
    <if test="_parameter.containsKey('event')">  
        AND event = #{event,jdbcType=VARCHAR})  
    </if>  
</select>  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM