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>
相关推荐
Test-Sunny3 小时前
多个定时器同时工作时,会出现哪些常见的bug ,如何解决??(定时任务未实时更新但刷新后正常的问题分析)
功能测试·bug·集成测试
用手码出世界12 小时前
【Linux】进程池bug、命名管道、systemV共享内存
linux·运维·bug
·云扬·1 天前
【BUG】Redis RDB快照持久化及写操作禁止问题排查与解决
数据库·redis·bug
筱戥芊茹3 天前
RK3588上Linux系统编译C/C++ Demo时出现BUG:The C/CXX compiler identification is unknown
linux·c语言·c++·嵌入式硬件·bug
一杯咖啡*_*4 天前
VSCode优雅的使用debug
ide·vscode·python·编辑器·bug
·云扬·6 天前
【BUG】阿里云服务器数据库远程连接报错
服务器·阿里云·bug
·云扬·6 天前
【BUG】远程连接阿里云服务器上的redis报错
服务器·阿里云·bug
upp6 天前
[bug]解决vscode+cline使用mcp服务报错spawn npx enoent spawn npx enoent
ide·vscode·bug·js
shenxiaolong_code6 天前
编译器bug ?
c++·bug·meta programming·compiler bug
枸杞配码7 天前
arthas线上不停机修改bug
ide·pycharm·bug