欄位索引超過許可范圍:1,欄位數:0。; nested exception is org.postgresql.util.PSQLException: 欄位索引超過許可范圍:1,欄位數:0。


在開發的過程中遇到這個問題,真的很痛苦,網上說的各種做法我都試了一遍,但是都不好使。分頁情況遇到的。

無奈之下,只能投機取巧了,修改后的mapper.xml文件如下:

 <select id="queryItemPage" resultMap="reBranch"
            parameterType="com.picc.hfms.budget.dto.BrBudgetItem">
        select * from (
        select row_number()over(partition by item_id order by audit_date desc )rn, test.* from (
        select a.item_id,
        a.budget_id,
        a.item_code,
        a.item_name,
        a.total_amount,
        a.org_code,
        a.item_type,
        a.service_type,
        a.is_hairpin,
        a.hairpin_num,
        a.product_code,
        a.product_name,
        a.service_code,
        a.service_name,
        a.remark,
        a.insert_oper,
        a.insert_time,
        a.update_time,
        a.update_oper,
        b.budget_code,
        b.budget_name,
        b.actual_total_amount,
        c.status,
        c.audit_date,
        c.item_trace_id
        from t_budget_item_branch  a
        join  T_BUDGET_ITEM_BRANCH_TRACE c on a.item_id=c.item_id
        left   join  T_BUDGET_BRANCH b on a.budget_id=b.budget_id
        )  test  ) aaa where rn='1'
        <if test="Status!=null and Status != ''">
            and status like #{Status}
        </if>
        <if test="itemName!=null and itemName != ''">
            and item_name like #{itemName}
        </if>
        <if test="itemCode!=null and itemCode != ''">
            and item_code like #{itemCode}
        </if>
        <if test="isHairpin!=null and isHairpin != ''">
            and is_hairpin like #{isHairpin}
        </if>
        <if test="budgetId!=null and budgetId != ''">
            and budget_id = cast(#{budgetId} as NUMERIC )
        </if>
        <if test="orgCode!=null and orgCode != ''">
            and org_code like #{orgCode}
        </if>
        <if test="itemType!=null and itemType != ''">
            and item_type like #{itemType}
        </if>
        <if test="itemId!=null and itemId != ''">
            and item_id = cast(#{itemId} as NUMERIC )
        </if>
        <if test="itemName!=null and itemName != ''">
            and item_name like #{itemName}
        </if>
        order by update_time desc
      offset (#{page}- 1)* #{limit} limit #{limit}  手動分頁
    </select>
Dao層原來的寫法
Page<BranchVo> brL = branchBudgetDao.queryItemPage(pageParam,brBudgetItem);
Dao層改變后的寫法
Page<BranchVo> brL = branchBudgetDao.queryItemPage(brBudgetItem);//不傳分頁參數,分頁參數,放到BrBudgetItem實體類中,添加相應的分頁屬性,limit-頁大小   page起始頁碼
經過修改,就好使了。
總結:傳pageparam的時候,mapper.xml文件中查詢的單表,所以沒有問題,但是現在查詢的是多表,所以這樣寫可能就不行,所以要換一種寫法。僅個人愚見。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM