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