MyBatis动态SQL使用,传入参数Map中的Key判断
2018-02-28 10:29
567 查看
当使用Map做为参数时,可以用_parameter.containsKey(变量名)来判断map中是否包含有些变量:[html] view plaincopy
<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>
<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>
相关文章推荐
- MyBatis动态SQL使用,传入参数Map中的Key判断
- MyBatis动态SQL使用,传入参数Map中的Key判断
- MyBatis动态SQL使用,传入参数Map中的Key判断
- MyBatis动态SQL使用,传入参数Map中的Key判断
- MyBatis 动态SQL使用心得之Map中Key判断
- foreach属性-动态-mybatis中使用map类型参数,其中key为列名,value为列值
- foreach属性-动态-mybatis中使用map类型参数,其中key为列名,value为列值
- MyBatis中的动态SQL,实现不确定条件的CRUD-----使用Map来传递查询的参数
- foreach属性-动态-mybatis中使用map类型参数,其中key为列名,value为列值
- MyBatis参数传入集合之foreach动态sql
- MyBatis参数传入集合之foreach动态sql
- mybatis 动态sql之Map参数
- mybatis sql in 查询(mybatis sql语句传入参数是list)mybatis中使用in查询时in怎么接收值
- MyBatis动态参数为数组、list、Map,并使用oder by给结果排序
- mybatis中使用map类型参数,其中key为列名,value为列值
- MyBatis参数传入集合之foreach动态sql
- mybatis使用map传入多个参数
- MyBatis参数传入集合之foreach动态sql
- MyBatis参数传入集合之foreach动态sql
- MyBatis参数传入集合之foreach动态sql