Oracle 的分页查询,myBatis 配置文件

前端送的参数:

start - 开始记录数,rowStart ,从 0 开始

limit - 每页记录数,pageSize

 1     <!-- Oracle 11g -->
 2     
 3     <select id="selectList" parameterType="category.Bean"
 4         resultType="category.Bean">
 5         
 6         <![CDATA[  
 7         
 8         SELECT * FROM 
 9         (
10             SELECT A.*, ROWNUM rowNumber 
11             FROM (
12                 SELECT 
13                     "id",
14                     "groupCode",
15                     "parentId",
16                     "number",
17                     "name",
18                     "description",
19                     "value",
20                     "status",
21                     "insertedDatetime",
22                     "insertUserId",
23                     "checkedDatetime",
24                     "checkerId",
25                     "comment"
26                 FROM "t_category"
27                 where 1=1                
28                     ]]>
29                 
30                     <if test="id!=null and id != '' and id != '0'"> and "id" = #{id}</if>
31                     <if test="groupCode!=null and groupCode != ''"> and "groupCode" = #{groupCode}</if>
32                     <if test="parentId!=null and parentId != ''"> and "parentId" = #{parentId}</if>
33                     <if test="number!=null and number != ''"> and "number like '%${number}%'</if>
34                     <if test="name!=null and name != ''"> and "name" like '%${name}%'</if>
35                     <if test="description!=null and description != ''"> and "description" = #{description}</if>
36                     <if test="value!=null and value != ''"> and "value" = #{value}</if>
37                     <if test="status!=null and status != ''"> and "status" = #{status}</if>
38                     <if test="insertedDatetime!=null and insertedDatetime != ''"> and "insertedDatetime" = #{insertedDatetime}</if>
39                     <if test="insertUserId!=null and insertUserId != ''"> and "insertUserId" = #{insertUserId}</if>
40                     <if test="checkedDatetime!=null and checkedDatetime != ''"> and "checkedDatetime" = #{checkedDatetime}</if>
41                     <if test="checkerId!=null and checkerId != ''"> and "checkerId" = #{checkerId}</if>
42                     <if test="comment!=null and comment != ''"> and "comment" = #{comment}</if>
43                     
44                     <![CDATA[ 
45                     
46                 ) A   
47             WHERE ROWNUM <= ( #{start} + #{limit} )
48         )
49         WHERE rowNumber > #{start}
50         
51         ]]>
52         
53     </select>
原文地址:https://www.cnblogs.com/livon/p/3293214.html