問題描述: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)
我的問題是根據需要唯一的數據的那張表進行左連接而不是內連接