最近做的项目涉及Mybatis条件查询,期间遇到好多问题,最后又很神奇的消失了。现将代码贴上来,为以后的开发铺路。
<!-- Select Parameter with condition-->
<select id="selectParameter" resultMap="BaseResultMap" parameterType="com.sgcc.devops.dao.entity.Parameter">select
from dop_parameter where 1=1
<if test="paraName != null and paraName !='' ">
AND PARA_NAME like CONCAT(CONCAT('%',#{paraName}),'%')
</if>
AND PARA_TYPE = #{paraType,jdbcType=VARCHAR}
</if>
</select>