nested exception is org.apache.ibatis.binding.BindingException: Parameter “startIndex” not found.

在做後臺項目查詢MQ消息的時候,報錯
代碼如下:
  • biz
    @Override
    protected List queryPaging(int startIndex, int pageSize, Object... objs) {
        QueryPagingUrlMessageRequest request = (QueryPagingUrlMessageRequest) objs[0];
        List<Integer> ids = null;
        if (request.getItemId() != null){
            ids = itemService.getConfigList(request.getItemId(),Constants.URL_MESSAGE_LIST);
            if (CollectionUtils.isEmpty(ids)){
                return new ArrayList<>();
            }
        }
        UrlMessageCondition condition = new UrlMessageCondition();
        BeanUtils.copyProperties(request,condition);
        condition.setIds(ids);
        return urlMessageService.pagingQuery(condition,startIndex,pageSize);
    }
這裏的pagingQuery方法中出現了startIndex,最終是爲了mabatis中limit時求開始索引

starrtIndex = pageSize * (pageIndex - 1)

  • service
    public List<UrlMessage> pagingQuery(UrlMessageCondition condition, int startIndex, int pageSize) {
        return mapper.selectByPidAndurlMessageAndCreator(condition,startIndex,pageSize);
    }
  • mapper
    List<UrlMessage> selectByPidAndurlMessageAndCreator(
            @Param("condition") UrlMessageCondition condition,
            @Param("startIndex") int startIndex,
            @Param("pageSize") int pageSize);
!!!問題出在了這裏!!!,@Param(“startIndex”) int startIndex ,拼寫錯誤·······導致sql語句的limit #{startIndex},#{pageSize} 中找不到startIndex
  • .xml
<select id="selectByPidAndurlMessageAndCreator" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from wpm_config_url_message
    where
    STATUS=1
    <if test="condition.pid != null">
      and PID =#{condition.pid}
    </if>
    <if test="condition.name != null">
      and NAME like CONCAT('%',#{condition.name},'%')
    </if>
    <if test="condition.topic != null">
      and TOPIC like CONCAT('%',#{condition.topic},'%')
    </if>
    <if test="condition.creator != null">
      and CREATOR =#{condition.creator}
    </if>
    <if test="condition.ids != null">
      and ID in
      <foreach collection='condition.ids' item='id'
               open='('
               close=')'
               separator=','>
        #{id}
      </foreach>
    </if>
    <if test="condition.responsibleOwner != null">
      and RESPONSIBLE_OWNER =#{condition.responsibleOwner}
    </if>
    order by ID
    limit #{startIndex},#{pageSize}
  </select>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章