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>
相关推荐
天才测试猿17 小时前
快速定位bug,编写测试用例
自动化测试·软件测试·功能测试·测试工具·职场和发展·测试用例·bug
福大大架构师每日一题1 天前
PyTorch v2.9.1 发布:重要 Bug 修复与性能优化详解
人工智能·pytorch·bug
黑臂麒麟2 天前
Electron&OpenHarmony 跨平台实战开发(bug):npm 安装 Electron 依赖常见错误排查
electron·npm·bug·openharmony
CIb0la2 天前
Complete Bug Bounty tool List for free
linux·运维·bug
欧恩意2 天前
【Viusal Studio】关于增量链接机制
汇编·windows·bug
Austindatabases2 天前
SQLite 开发中的数据库开发规范 --如何提升业务系统性能避免基础BUG
数据库·oracle·sqlite·bug·数据库开发
万粉变现经纪人2 天前
如何解决 pip install 代理报错 407 Proxy Authentication Required 问题
windows·python·pycharm·beautifulsoup·bug·pandas·pip
爱尔兰极光3 天前
软件测试--BUG篇
bug·压力测试·测试
hadage2333 天前
windows alt + tab 切换窗口时会强制把我的中文键盘的中英文输入改为中文这个bug的曲线救国方式 da
bug
烧酒同学3 天前
【Qt】QScrollArea的滑动条无法拖动(已解决)
qt·bug