标签:enc 1.0 自测 添加 shm dex start index AC
1.在mybatis的公共mapping中添加下面设置
三层嵌套方式和用 row_number的方式都能到达效果,但是性能优劣众说纷纭我没亲自测试过。
<?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" > <mapper namespace="common.mapping.CommonMapper"> <!-- ①采用rownum关键字(三层嵌套)有人说这个比下面更好 --> <sql id="Oracle_Pagination_Head"> <if test="pageIndex !=null and pageSize !=null"> <![CDATA[select y.* from(select z.*,rownum as oracleStart from (]]> </if> </sql> <sql id="Oracle_Pagination_Tail"> <if test="pageIndex != null and pageSize != null"> <![CDATA[ ) z where rownum <= (#{pageIndex}+1) * #{pageSize} ) y where y.oracleStart > #{pageIndex} * #{pageSize} ]]> </if> </sql> <!-- ②采用row_number解析函数进行分页(效率更高) --> <!-- SELECT xx.* FROM( SELECT t.*,row_number() over(ORDER BY o_id)AS num FROM t_order t )xx WHERE num BETWEEN 5 AND 15 --> <sql id="Oracle_PageRowNuber_Head"> <if test="pageIndex !=null and pageSize !=null"> <![CDATA[SELECT xx.* FROM( SELECT t.*,row_number() over(ORDER BY order_no)AS num FROM (]]> </if> </sql> <sql id="Oracle_PageRowNuber_Tail"> <if test="pageIndex != null and pageSize != null"> <![CDATA[ )t ) xx WHERE num BETWEEN #{pageIndex} * #{pageSize} AND (#{pageIndex}+1)* {pageSize}]]> </if> </sql> </mapper>
2. 后面直接引用
<select id="getListPageData" parameterType="java.util.HashMap" resultType="common.model.Row"> <include refid="common.mapping.CommonMapper.Oracle_Pagination_Head" /> select ......... <include refid="common.mapping.CommonMapper.Oracle_Pagination_Tail" /> </select>
在mybatis 采用mapping文件 中的 oracle分页 SQL 配置在一个公用mapping中供后面引入使用
标签:enc 1.0 自测 添加 shm dex start index AC
原文地址:https://www.cnblogs.com/jkyxs/p/9141069.html