ssm整合中使用pageinfo插件的分页数据位移问题记录

时间: --2020/5/4

情景:修改某条记录后数据发生位移

ssm整合中使用pageinfo插件的分页数据位移问题记录

原因:mybatis 的一个查询sql不符合功能要求

<!--  查询员工同时带部门信息 -->

    <!-- <select id="selectByExampleWithDept"

       parameterType="com.atguigu.crud.bean.EmployeeExample"

       resultMap="WithDeptResultMap">

       select

       <if test="distinct">

           distinct

       </if>

       <include refid="WithDept_Column_List" />

       FROM tbl_emp e

       LEFT JOIN tbl_dept d ON e.d_id=d.dept_id

       <if test="_parameter != null">

           <include refid="Example_Where_Clause" />

       </if>

       <if test="orderByClause != null">

           order by ${orderByClause}

       </if>

    </select> -->

<!--  查询员工同时带部门信息 并根据emp_id排序 asc -->

    <select id="selectByExampleWithDept"

       parameterType="com.atguigu.crud.bean.EmployeeExample"

       resultMap="WithDeptResultMap">

       select

       <include refid="WithDept_Column_List" />

       FROM tbl_emp e

       LEFT JOIN tbl_dept d ON e.d_id=d.dept_id

       <if test="_parameter != null">

           <include refid="Example_Where_Clause" />

       </if>

           order by e.emp_id

    </select>

总结:sql语句的实现不符合功能,不知道mybatis自动生成的一些代码的功能

一开始怀疑是pageinfo插件的问题,在网上搜索后,发现是mybatis的mapper.xml实现的问题,修改sql达到分页要求;