mybatis where条件拼写

以前用where 1=1拼后边的 and条件,看官方文档,以下示例不错。

<select id="selectBaseEduInfos" resultMap="BaseResultMap"
parameterType="cn.com.china.entity.BaseEduInfo" useCache="true">
select
<include refid="Base_Column_List" />
from T_DT_BASE_EDU_INFO
<trim prefix="WHERE" prefixOverrides="AND |OR ">
<if test="parentCode != null">
and PARENT_CODE = #{parentCode,jdbcType=VARCHAR}
</if>
<if test="level != null">
and LEVEL = #{level,jdbcType=INTEGER}
</if>
<if test="sequence != null">
and SEQUENCE = #{sequence,jdbcType=INTEGER}
</if>
</trim>
</select>

你可能感兴趣的:(mybatis,where)