43.bug:mapper接口参数使用@param重命名导致的错误

错误信息:Nested exception is org.apache.ibatis.binding.bindingException:parameter inVo not found 

public interface UserMapper{
//查询用户列表

User queryUserList(@Param ("inVo") UserInVo userInVo);
}

对应的UserMapper如下:

<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使用重命名后的参数名

<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. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-06-09 11:46:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-06-09 11:46:03       101 阅读
  3. 在Django里面运行非项目文件

    2024-06-09 11:46:03       82 阅读
  4. Python语言-面向对象

    2024-06-09 11:46:03       91 阅读

热门阅读

  1. 如何评价GPT-4o?【模板】

    2024-06-09 11:46:03       31 阅读
  2. 新电脑必装的7款软件,缺一不可

    2024-06-09 11:46:03       30 阅读
  3. Docker无法stop或者rm指定容器

    2024-06-09 11:46:03       29 阅读
  4. 「前端+鸿蒙」鸿蒙应用开发-TS函数

    2024-06-09 11:46:03       26 阅读
  5. 轻量管理内核复杂级别的项目

    2024-06-09 11:46:03       28 阅读
  6. Float浮动

    2024-06-09 11:46:03       29 阅读
  7. Android 日志实时输出

    2024-06-09 11:46:03       32 阅读
  8. 力扣1248.统计优美子数组

    2024-06-09 11:46:03       27 阅读
  9. 定位器追踪器怎么连接手机

    2024-06-09 11:46:03       23 阅读