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>
相关推荐
ALGO阿狗5 天前
SimpleDateFormat(“YYYY-MM-dd“)格式化时间出现了bug?
bug
爱学习的小可爱卢6 天前
JavaSE基础-Java异常体系:Bug定位终极指南
java·bug·javase
GeekyGuru6 天前
代码诊疗室——疑难Bug破解战
bug
嵌入式×边缘AI:打怪升级日志9 天前
9.2.3 UART 驱动严重 Bug(保姆级讲解)
bug
qq_242188633211 天前
代码诊疗室——疑难Bug破解战
bug
Moshow郑锴13 天前
Java SpringBoot 疑难 Bug 排查思路解析:从“语法正确”到“行为相符”
java·spring boot·bug
人间花海13 天前
BUG终结者:挑战你的调试极限
bug
2401_8582861113 天前
OS54.【Linux】System V 共享内存(3) “共享内存+管道“修bug记录
linux·运维·服务器·算法·bug
Kurbaneli14 天前
代码诊疗室——疑难Bug破解战
bug
Mr -老鬼16 天前
从 0 到 1 落地:Rust + Salvo 实现用户系统与 Bug 管理系统
开发语言·rust·bug