Mybatis条件查询

来源:互联网 发布:chemist软件 编辑:程序博客网 时间:2024/05/24 01:55

最近做的项目涉及Mybatis条件查询,期间遇到好多问题,最后又很神奇的消失了。现将代码贴上来,为以后的开发铺路。

<!-- Select Parameter with condition-->

<select id="selectParameter" resultMap="BaseResultMap" parameterType="com.sgcc.devops.dao.entity.Parameter">

select


<include refid="Base_Column_List" />
from dop_parameter where 1=1

<if test="paraName != null and paraName !='' ">
AND PARA_NAME like CONCAT(CONCAT('%',#{paraName}),'%')

</if>


<if test="paraType != null and paraType != '' ">
AND PARA_TYPE = #{paraType,jdbcType=VARCHAR}
</if>

</select>
1 0