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 小时前
bug 记录 - 使用 el-dialog 的 before-close 的坑
前端·javascript·bug
顽强d石头6 小时前
bug:undefined is not iterable (cannot read property Symbol(Symbol.iterator))
前端·bug
阿松のblog1 天前
opencv使用经典bug
人工智能·opencv·bug
学习啷个办1 天前
centos挂载目录满但实际未满引发系统宕机
bug
我们的五年3 天前
【Qt】Bug:findChildren找不到控件
开发语言·qt·bug
seiyaaa3 天前
Claude Opus solved my white whale bug today that I couldn‘t find in 4 years
bug
六天测试工程师3 天前
做好 4个基本动作,拦住性能优化改坏原功能的bug
服务器·性能优化·bug
良辰美景好时光3 天前
keepalived定制日志bug
linux·运维·bug
CYRUS STUDIO4 天前
FART 自动化脱壳框架一些 bug 修复记录
android·bug·逆向·fart·脱壳
布谷歌6 天前
一个Mybatisplus组件扫描不当引起的bug:弄巧成拙,认真的锅,自我怀疑
java·开发语言·bug