对于PageHelper分页插件,Mybaties使用association标签后统计数量不正确的处理

问题描述:不论如何设置分页大小(每页展示的数据),每次返回的总数据量总是与设置的分页大小相同。

在这里插入图片描述

<resultMap id="userBoResultMap" type="com.platform.system.model.vo.AdminVO">
        <id column="id" property="id" jdbcType="VARCHAR"/>
        <result column="username" property="username" jdbcType="VARCHAR"/>
        <result column="password" property="password" jdbcType="VARCHAR"/>
        <result column="nickname" property="nickname" jdbcType="VARCHAR"/>
        <result column="status" property="status" jdbcType="TINYINT"/>
        <result column="createTime" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="lastUpdate" property="lastUpdate" jdbcType="TIMESTAMP"/>
        <result column="createUser" property="createUser" jdbcType="VARCHAR"/>
        <result column="authorizeOrg" property="authorizeOrg" jdbcType="VARCHAR"/>
        <result column="orgName" property="orgName" jdbcType="VARCHAR"/>
        <association property="adminExtendBO" javaType="com.platform.system.model.bo.AdminExtendBO">
            <result column="userId" property="userId" jdbcType="VARCHAR"/>
            <result column="orgId" property="orgId" jdbcType="VARCHAR"/>
            <result column="job" property="job" jdbcType="VARCHAR"/>
            <result column="phone" property="phone" jdbcType="VARCHAR"/>
            <result column="address" property="address" jdbcType="VARCHAR"/>
            <result column="swjgdm" property="swjgdm" jdbcType="VARCHAR"/>
        </association>
        <collection property="rolesList" ofType="com.platform.system.model.Role">
            <id column="roleId" property="id"/>
            <result column="roleName" property="roleName"/>
            <result column="rStatus" property="status"/>
            <result column="ds_type" property="ds_type"/>
        </collection>
    </resultMap>

处理前接口返回(total错误)

默认分页大小为10条数据,返回的total也同样是10。
在这里插入图片描述

处理后接口返回(total正确)

在这里插入图片描述

解决方案

1.自定义count统计

在这里插入图片描述
在这里插入图片描述

2.在Controller返回时,重新设置返回结果的大小。

在这里插入图片描述

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值