Private arrayList queryResult = null; private int pageize = 0; file: // Make each page show private int count = 0; file: / / How many record private int Pagenumber = 0; file: // is currently the first A number of pages of private int potes = 0; file: / / How many pages of a total of a total of a total of the records per page Public void setpagesize (int pagesize) {this.pageSize = pagesize;}
Public int getpagesize () {return this.pageSize;
File: // Total record number public void setcounts (int counts) {this.counts = counts;}
Public int getcounts () {return this.counts;} file: // Total number PUBLIC VOID SetPages (int pages) {this.pages = pages;
Public int getpages () {returnid.
File: // Current page number public void setpagenumber (int Pagenumber) {this.pagenumber = Pagenumber;}
Public int getpagenumber () {ix (this.pagenumber> this.pages && this.pagenumber> 1) {this.pagenumber = this.pages;} Return this.pagenumber;
Public void setQueryResult (arraylist al) {this.queryResult = al;}
Public arraylist getQueryResult () {return this.queryResult;}
Public int getStartIndex () {return (this.pagenumber - 1) * this.pagesize;
Public int getAllPages () {return this.counts% this.pageSize == 0? this.counts / this.pageSize: this.counts / this.pageSize 1;} public void getQueryResult () {system.out.println (" has enter into QueryresultForm "); setPagesize (Constants.DEFAULTPAGESIZE); try {// Sys_Code sc = new Sys_Code (); Configuration cf = new Configuration () addClass (Sys_Code.class);. SessionFactory sf = cf.buildSessionFactory (); Session session = sf.openSession (); file: // Total number of records query querycounts = session.createQuery ("Select count (*) from sys_code as sc"); list querylist = querycounts.list (); if (querylist) .isempty ()) {setcounts (0); setpages (0);} else {setcounts (qerylist.get (0) .tostring ()); setAllPages ());} Query query = session.createQuery ("from sys_code as sc"); file: // Set the query query query.setfirstResult (getStartIndex ()) from the proprietary record; file: // set once How many records of query query record Query.SetMaxResults (getPagesize ()); list list = query.list ();
IF (! list.iserpty ()) {this.queryResult = new arraylist (); arraylist midal = (arraylist) list; for (int i = 0; i