43.bug:mapper接口参数使用@param重命名导致的错误

错误信息:Nested exception is org.apache.ibatis.binding.bindingException:parameter inVo not found

java 复制代码
public interface UserMapper{
//查询用户列表

User queryUserList(@Param ("inVo") UserInVo userInVo);
}

对应的UserMapper如下:

sql 复制代码
<select id="queryUserList" returnType="User">
    selelct id,name,age,phone,createtime from tb_user A
    <where>
        <if test="inVo.name!='' and inVo.name!=null">
            A.name=#{inVo.name}
        </if>
        <if test=" userInVo.age!=null">
            A.age=#{userInVo.age}
        </if>
    </where>
    order by A.createtime desc
</select>

原因 :mappper 的接口方法中,因为使用@Param注解,重命名入参,但是SQL中没有使用重命名的参数名导致

改正:SQL使用重命名后的参数名

sql 复制代码
<select id="queryUserList" returnType="User">
    selelct id,name,age,phone,createtime from tb_user A
    <where>
        <if test="inVo.name!='' and inVo.name!=null">
            A.name=#{inVo.name}
        </if>
//错误改正:userInVo改正为:inVo
        <if test=" inVo.age!=null">
            A.age=#{inVo.age}
        </if>
    </where>
    order by A.createtime desc
</select>
相关推荐
kunkun1011 天前
关于软件测试中的bug
python·bug·压力测试
用键盘当武器的秋刀鱼2 天前
springboot-bug
java·spring boot·bug
星辰&与海3 天前
报错 watcgdog: BUG; soft lockup -CPU#0 stuck for 26s! [swapper/0:1]
bug
无人等人3 天前
CyberRT(apollo) 定时器模块简述及bug分析
bug
fengdongnan3 天前
bug小记
bug
天才测试猿3 天前
解决Selenium元素拖拽不生效Bug
linux·自动化测试·软件测试·python·selenium·测试工具·bug
四角小裤儿儿3 天前
软件测试(三)——Bug篇
功能测试·面试·单元测试·bug
开发者工具分享4 天前
测试是如何跟进和管理 bug
bug
Htht1116 天前
【Linux】之【Bug】VMware 虚拟机开机 一直卡在黑屏左上角下划线闪烁界面
linux·运维·bug
你的坚定8 天前
记Android12上一个原生bug引起的system_server crash
bug