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>
相关推荐
初圣魔门首席弟子1 天前
c++ bug 记录(merge函数调用时错误地传入了vector对象而非迭代器。)
java·c++·bug
Qiuner1 天前
历劫波,明真我——Debug Commune
ai·开源·bug·debug·信息差·信息·交流
川石课堂软件测试3 天前
什么是BUG,你对BUG的了解有多少?
android·linux·服务器·python·功能测试·bug·安全性测试
仰望星空的凡人3 天前
【BUG排查】基于RH850F1KMS1的主控出现系统中断错误,调试FEIC的值为0x11
单片机·bug·rh850·renesas
Vanranrr3 天前
Git Commit Message 最佳实践:从一次指针Bug说起
git·bug
初圣魔门首席弟子4 天前
c++ bug 函数定义和声明不一致导致出bug
开发语言·c++·bug
xuyuan19984 天前
修复1个Bug,引爆3个新Bug?回归测试的智慧
功能测试·测试用例·bug
三十_A4 天前
【实录】使用 patch-package 修复第三方 npm 包中的 Bug
前端·npm·bug
BrightMZM4 天前
记录一下Unity的BUG,Trial Version
unity·bug·打包·trial
一只自律的鸡5 天前
【bug日记】python找不到包
bug