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>
相关推荐
爱编程的鱼2 天前
想学编程作为今后的工作技能,学哪种语言适用性更强?
开发语言·算法·c#·bug
拽着尾巴的鱼儿2 天前
fixed-bug:JPA 关联关系的对象序列化循环引用问题
spring·bug·jpa
南汐以墨2 天前
BUG与测试用例
测试用例·bug
Mr. zhihao2 天前
Java 反序列化中的 boolean vs Boolean 陷阱:一个真实的 Bug 修复案例
java·bug·lua
初圣魔门首席弟子2 天前
vscode多文件编程bug记录
java·vscode·bug
-雷阵雨-3 天前
软件测试全解析:Bug生命周期与争议解决
bug
南林yan3 天前
Bug: 升级内核后有线网络无法使用
bug
月巴月巴白勺合鸟月半3 天前
一个DevExpress的Docx文件处理的Bug的解决
c#·bug
ao_lang3 天前
软件测试-BUG篇
bug
技术小黑屋_3 天前
Vibe Coding 真正的问题并不是 Bug
bug