1. Add the following settings in the MyBatis public mapping
Three layers of nesting and using row_number can reach the effect, but the performance of the pros and cons I have not personally tested.
<?XML version= "1.0" encoding= "UTF-8"?><!DOCTYPE Mapper Public "-//mybatis.org//dtd mapper 3.0//en" "Http://mybatis.org/dtd/mybatis-3-mapper.dtd "><Mappernamespace= "Common.mapping.CommonMapper"> <!--① using rownum keyword (three-layer nesting) someone says this is better than the bottom. - <SQLID= "Oracle_pagination_head"> <ifTest= "PageIndex!=null and PageSize!=null"> <! [Cdata[Select Y.* from (select Z.*,rownum as Oraclestart from (]]> </if> </SQL> <SQLID= "Oracle_pagination_tail"> <ifTest= "PageIndex! = null and PageSize! = NULL"> <! [Cdata[) Z where rownum <= (#{pageindex}+1) * #{pagesize}) y where Y.oraclestart > #{pageindex} * #{pagesize}]]> </if> </SQL> <!--② using Row_number analytic functions for paging (higher efficiency) - <!--Select xx.* from (select T.*,row_number () over (ORDER by o_id) as Num from T_order t) xx WHERE num between 5 an D - <SQLID= "Oracle_pagerownuber_head"> <ifTest= "PageIndex!=null and PageSize!=null"> <! [Cdata[Select xx.* from (select T.*,row_number () over (ORDER by order_no) as Num from (]]> </if> </SQL> <SQLID= "Oracle_pagerownuber_tail"> <ifTest= "PageIndex! = null and PageSize! = NULL"> <! [Cdata[) t) xx WHERE num between #{pageindex} * #{pagesize} and (#{pageindex}+1) * {pageSize}]]> </if> </SQL></Mapper>
2. Following the direct reference
<SelectID= "Getlistpagedata"ParameterType= "Java.util.HashMap"Resulttype= "Common.model.Row"> <includerefID= "Common.mapping.CommonMapper.Oracle_Pagination_Head" />Select ... ..<includerefID= "Common.mapping.CommonMapper.Oracle_Pagination_Tail" /></Select>
Oracle Paging SQL configuration in MyBatis with mapping files is used in a common mapping for later ingestion