PageHelper结合mybatis使用返回的页数中的数据条数与size不符

    技术2025-10-28  14

    由于pagehelper会自动在sql语句中添加limit进行数据条数的限制,所以当数据条数的colums出现重复时会出现数据条数显示异常,从而导致得到的数据是对的,但是页数不一致。 解决办法: 1:在《collection》中使用内查询 2:在标签内检查是否存在名称相同的行,进行重命名 3:修改sql语句,对列进行重命名建立对应关系

    <resultMap id="PatientAll" type="com.xht.entity.Patient"> <result column="pid" jdbcType="INTEGER" property="pid"></result> <result column="pname" jdbcType="VARCHAR" property="pname"></result> <result column="sex" jdbcType="VARCHAR" property="sex"></result> <result column="age" jdbcType="INTEGER" property="age"></result> <result column="birthday" jdbcType="VARCHAR" property="birthday"></result> <result column="idcard" jdbcType="VARCHAR" property="idcard"></result> <result column="address" jdbcType="VARCHAR" property="address"></result> <result column="levelid" jdbcType="INTEGER" property="levelid"></result> <result column="deptid" jdbcType="INTEGER" property="deptid"></result> <result column="doctorid" jdbcType="INTEGER" property="doctorid"></result> <result column="createdate" jdbcType="DATE" property="createDate"></result> <result column="cost" jdbcType="INTEGER" property="cost"></result> <result column="pstatus" jdbcType="VARCHAR" property="pstatus"></result> <result column="status" jdbcType="INTEGER" property="status"></result> <association property="doc" javaType="com.xht.entity.Doctor"> <result column="doctorid" jdbcType="INTEGER" property="id"></result> <result column="dname" jdbcType="VARCHAR" property="dname"></result> <result column="deptid" jdbcType="INTEGER" property="deptid"></result> </association> <association property="level" javaType="com.xht.entity.Level" > <result column="levelid" jdbcType="INTEGER" property="id"></result> <result column="levelname" jdbcType="VARCHAR" property="levelname"></result> <result column="cost" jdbcType="INTEGER" property="cost"></result> </association> <association property="dept" javaType="com.xht.entity.Dept" > <result column="deptid" jdbcType="INTEGER" property="id"></result> <result column="deptname" jdbcType="VARCHAR" property="deptname"></result> </association> </resultMap> select a.*,b.*,c.*,d.* , b.id as doctorid, c.id as levelid, d.id as deptid from patient a left join doctor b on a.doctorid=b.id left join level c on a.levelid=c.id left join dept d on a.deptid=d.id where a.createdate=curdate()
    Processed: 0.009, SQL: 9