The scope of this article is only true paging. The paging mentioned below also refers to real paging.).
Paging commonalities
Comparison of Three data paging Methods
Special Page of MySql database
Common Paging for Oracle databases
Select T. *, rownum rn from () T where rownum <PageNo * PageSize) Where rn >=( PageNo-1) * PageSize
Select A. *, rownum rn from () A where rownum <41) Where rn> = 20
Common SQL server data Paging
5 records that follow the records displayed on the first pageThat is, when the userID field is sorted in descending order, they are the five records except the first page of data, that is, their userids are not in the userID on the first page, the SQL statement has a not in which can be used. First, we sort the UserID in descending order and query the UserID of the data used on the first page. The SQL statement and execution result are as follows:
Select 5 userID from t_User order by userID asc) Order by userID asc
Select top (n-1) * 5 userID from t_User order by userID asc) Order by userID asc
Paging Of The Hibernate framework
Public class AbstractPageManager extends HibernateDaoSupport {/*** Based on the HQL statement, the HQL statement for finding the total number of records is as follows: * select... from Organization o where o. parent is null * after conversion, We can get: * select count (*) from Organization o where o. parent is null ** @ param hql * @ return */private String getCountQuery (String hql) {// retrieves the from position int index = hql. indexOf ("from"); // return: if (index! =-1) {return "select count (*)" + hql. substring (index);} throw new SystemException ("invalid HQL query statement ");} /*** perform paging query based on HQL statements ** @ param hql HQL statement * @ param params multiple parameters in the HQL statement * @ param offSet query starts from the first few records *@ param pageSize: How many lines are displayed on each page * @ return */public PageModel searchPaginate (String hql, object [] params, int offSet, int pageSize) {// number of records String strCount = getCountQuery (hql); // Number of Query records query Query = getSession (). crea TeQuery (strCount); // assign multiple parameters in the HQL statement to Queryif (params! = Null & params. length> 0) {for (int I = 0; I <params. length; I ++) {query. setParameter (I, params [I]) ;}// get the number of query entries int intCount = (Long) query. uniqueResult ()). intValue (); // query the Organization record query = getSession (). createQuery (hql); // assign multiple parameters in the HQL statement to Queryif (params! = Null & params. length> 0) {for (int I = 0; I <params. length; I ++) {query. setParameter (I, params [I]) ;}/ ** the offSet setting starts from the first few records to query * pageSize setting how many lines are displayed per page */query. setFirstResult (offSet); query. setMaxResults (pageSize); // assemble PageModelPageModel pageModel = new PageModel (); pageModel. setDatas (query. list (); pageModel. setTotal (intCount); return pageModel ;}}