【报错解决: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>
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐



所有评论(0)