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>
相关推荐
zzc9212 小时前
Adobe Illustrator设置的颜色和显示的颜色不对应问题
adobe·bug·illustrator·错误·配色·透明度·底色
开-悟2 天前
嵌入式编程-使用AI查找BUG的启发
c语言·人工智能·嵌入式硬件·bug
一入JAVA毁终身2 天前
Data的时区格式BUG
bug
一入JAVA毁终身3 天前
处理Lombok的一个小BUG
java·开发语言·bug
SeaTunnel4 天前
SeaTunnel 社区月报(5-6 月):全新功能上线、Bug 大扫除、Merge 之星是谁?
大数据·开源·bug·数据集成·seatunnel
紫璨月4 天前
nginx反向代理的bug
运维·nginx·bug
从后端到QT4 天前
SRS流媒体服务器之本地测试rtc推流bug
bug·实时音视频
Java知识库14 天前
MySQL RC隔离级别惊现间隙锁:是bug吗?
数据库·mysql·bug
安卓机器14 天前
rom定制系列------红米note11 5G版 MTK芯片强解bl锁修复bug 官方系统 面具root批量线刷版
5g·bug
剽悍一小兔14 天前
一个小BUG引发的对Mybatis-Plus的模糊查询的思考
bug·mybatis