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>
相关推荐
万粉变现经纪人19 小时前
如何解决 pip install 代理报错 SOCKS5 握手失败 ReadTimeoutError 问题
java·python·pycharm·beautifulsoup·bug·pandas·pip
陌路物是人非1 天前
记一个 @Resource BUG
java·开发语言·bug
冬奇Lab2 天前
稳定性性能系列之四——异常日志机制与进程冻结:问题排查的黑匣子
android·性能优化·车载系统·bug
_OP_CHEN2 天前
【测试理论与实践】(三)测试BUG篇:从 BUG 本质到实战博弈,带你吃透软件测试的核心逻辑
运维·测试开发·产品运营·bug·压力测试·测试
-拟墨画扇-4 天前
Git | Bug分支操作
git·gitee·github·bug·gitcode
小凡子空白在线学习4 天前
Bug目录
bug
jiedaodezhuti5 天前
秒级定位线上Bug的一些命令
bug
l1t7 天前
修改一个触发PostgreSQL 17.2 bug的SQL
sql·postgresql·bug
包小黑7 天前
【Linux】bug登记好习惯:发现bug,用命令行截取对应日志
linux·bug
癫狂的兔子9 天前
【BUG】【Python】逆序取值为空
bug