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>
相关推荐
酷酷-16 小时前
彩虹易支付最新版源码及安装教程(修复BUG+新增加订单投诉功能)
html·php·bug
佛系小嘟嘟1 天前
Android-由switch-case和view.getId()引起的bug:错误:需要常量表达式 的解决办法
android·bug
未来可期LJ1 天前
【测试-BUG篇】软件测试的BUG知识你了解多少呢?
软件测试·bug
软件测试很重要1 天前
追梦无Bug的软件世界
bug
我又来搬代码了2 天前
【Android】【bug】ImageView设置scaleType不生效的问题
android·bug
吴恩达亲传弟子2 天前
【Bug】解决 Ubuntu 中 “error: Unable to Find Python3 Executable” 错误
linux·ubuntu·bug
john_hjy3 天前
8. Bug 与 Error
javascript·bug
鸽芷咕3 天前
【Python报错已解决】 Encountered error while trying to install package.> lxml
开发语言·python·bug
鸽芷咕4 天前
【Python报错已解决】[notice] A new release of pip available: 22.2 -> 22.2.2
开发语言·python·bug·pip
倩倩_ICE_王王4 天前
Apache安装后无法启动的问题“不能再本地计算机启动apache”
bug·apache