• org.apache.ibatis.binding.BindingException: Parameter 'xxx' not found.


    1. 情景重现

    1.1 Mapper 代码

    public interface DeviceFileInfoVOMapper {
    
        List<QueryFileDTO> selectVideoByField(String devId, Long chl,  Date startTime,  Date endTime, Pagination pagination);
    
    }

    1.2 XML 代码

      <select id="selectVideoByField"  resultMap="videoFileMap">
        SELECT file_id
        FROM t_device_file_info WHERE 1=1
        <trim>
          <if test="devId != null">
            AND dev_id=#{devId,jdbcType=VARCHAR}
          </if>
          <if test="chl != null">
            AND chl=#{chl,jdbcType=BIGINT}
          </if>
          <if test="startTime != null">
            AND start_time &gt;= #{startTime,jdbcType=TIMESTAMP}
          </if>
          <if test="endTime != null">
            AND end_time &lt;= #{endTime,jdbcType=TIMESTAMP}
          </if>
        </trim>
      </select>

    1.3 错误详情

    2. 解决方法

      在 Mapper 中定义的方法参数添加 @Param 注解,@Param 注解的值和xml中引用的参数名一致即可。

      @Param("devId"),则在xml中使用 #{devId}

    public interface DeviceFileInfoVOMapper {
    
        List<QueryFileDTO> selectVideoByField(@Param("devId") String devId, @Param("chl") Long chl, @Param("startTime")  Date startTime, @Param("endTime") Date endTime, Pagination pagination);
    
    }
  • 相关阅读:
    最长回文子串 leetcode
    leetcode Plus one
    n的阶乘末尾有几个0?
    求两数的最大公约数和最小公倍数
    汉诺塔
    求n的阶乘
    svn book
    求斐波那契数列第n项
    判断一个数是否是素数
    <C Traps and Pitfalls>笔记
  • 原文地址:https://www.cnblogs.com/virgosnail/p/10831423.html
Copyright © 2020-2023  润新知