使用PageHelper插件分頁結合mybatis返回的列表個數不對問題解決


問題描述:spring mvc+mybatis項目中,當使用PageHelper插件進行分頁查詢時,查到的總數據量值是正確的,但是查詢當前頁返回的列表個數不對。比如每頁查詢10條,返回2條或者3條。resultMap使用了association返回復雜屬性。

格式如下:

<resultMap type="orgDetail" id="porgDetailMap">
        <result property="" column="" />
        <association property="orgInfo"
            javaType="com.sinosig.jobSpace.orgmanage.model.BaseOrgModel">
            <id property="id" column="id" />
            <result property="" column="" />
            <result property="" column="" />
            <result property="" column="" />
            <result property="" column="" />
            <result property="" column="" />
        </association>

    </resultMap>

產生問題的原因是當resultMap使用<result />  <association/>返回,當<result />對應的屬性有重復值時,只加載一個。

解決方法:

resultMap中增加<id />的返回,保證數據的唯一性(出自http://blog.51cto.com/7532113/1908701)

我的問題是根據需要唯一的數據的那張表進行左連接而不是內連接


免責聲明!

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



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