用Mybatis写动态sql使用if判断的时候报错
原sql语句是:
<select id="getFkdw" resultMap="BmCodeItem">
select distinct t.* from w_bm_code_item t,w_bm_fkdw_bmxmb b,w_pm_project_dept_fpry p
where p.xmbid=b.xmbid and b.fkdwid=t.id and t.code_type=1010
<if test="userid != null"> and p.userid= #{userid,jdbcType=NUMERIC} </if>
order by t.code_item_name
</select>
改为:<select id="getFkdw" resultMap="BmCodeItem">
select distinct t.* from w_bm_code_item t,w_bm_fkdw_bmxmb b,w_pm_project_dept_fpry p
where p.xmbid=b.xmbid and b.fkdwid=t.id and t.code_type=1010
<if test="_parameter != null"> and p.userid= #{userid,jdbcType=NUMERIC} </if>
order by t.code_item_name
</select>
对于单个参数的传入与判断必须使用mybatis内置对象_parameter来处理