zoukankan      html  css  js  c++  java
  • 栏位索引超过许可范围: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文件中查询的单表,所以没有问题,但是现在查询的是多表,所以这样写可能就不行,所以要换一种写法。仅个人愚见。
  • 相关阅读:
    Oracle DB 管理数据库的空间
    五 Django 1.5.4 User Authentication 用户认证
    接口开放在即,先学招行做好微信内容营销
    WPF的ItemsControl设置数据源以及Binding使用
    WPF中后台代码停止RepeatBehavior=RepeatBehavior.Forever的办法
    WPF中使用RenderTransformOrigin来控制动画的起点
    使用Rectangle+ImageBrush来代替Image,解决图片模糊的问题
    WPF中Style文件引用另一个Style文件中的样式
    WPF中用后台C#代码为TabItem设置Background属性
    WPF中设置Border的BorderThickness属性会让背景图片产生模糊感
  • 原文地址:https://www.cnblogs.com/dongyaotou/p/12524981.html
Copyright © 2011-2022 走看看