【报错解决:Parameter ‘id‘ not found. Available parameters are...】
报错解决:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'id' not found. Available parameters are...
·
报错解决:【通用异常:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter ‘id’ not found. Available parameters are [dto, param1]】
报错内容:
报错原因:一般情况为业务层或Service中接口参数与mapper.xml中参数不一致导致。
boolean isExist(@Param("dto")MenuforimexDTO dto);
<select id="isExist" resultType="boolean" >
select count(t.id)
from menuforimex t
<where>
(t.code =#{code} or t.name =#{name})
<if test="id != null and id !=''">
and t.id != #{id}
</if>
and (current_date() >= t.start_date or t.start_date is null)
and (t.end_date >= current_date() or t.end_date is null)
and t.activity = true
</where>
</select>
比如我这里传的是实体对象,mapper中是直接写的字段,需要改为从实体对象中取字段数据,从而保持参数一致。
修改后:
<select id="isExist" resultType="boolean" >
select count(t.id)
from menuforimex t
<where>
(t.code =#{dto.code} or t.name =#{dto.name})
<if test="dto.id != null and dto.id !=''">
and t.id != #{dto.id}
</if>
and (current_date() >= t.start_date or t.start_date is null)
and (t.end_date >= current_date() or t.end_date is null)
and t.activity = true
</where>
</select>
更多推荐
已为社区贡献1条内容
所有评论(0)