Pagehelper Multiple SQL Paging

Source: Internet
Author: User

Before there is a requirement, in a page need to have more than one SQL paging query and then put in a list, show, but there will be a bug, that is, each time the page will show the first one to find all the data;

First page

Second page

Because the production environment is truncated, the first data is processed, all of which are different and not affected.

Look at the service method:

Public Map getinvoicelist (string epid, string parameter, int page, int pageSize) {Map result = new HashMap ();        The query invoice invoiced date is less than or equal to the first 2 days of date EndTime = Dateutil.adddays (-2);            Paging processing Map parammap = new HashMap ();            Parammap.put ("Epid", epid);            Parammap.put ("status", 10);        Parammap.put ("EndTime", endTime);        Pagehelper.startpage (page, pageSize); list<map> Oldmap = invoicemapper.reviewinvoicelist (PARAMMAP);//Can be reviewed invoice list<map> List = new ArrayList&lt  ;> ();//First inspection invoice list<map> totallist = new arraylist<> ();//Verifiable invoice sum if (null! = Oldmap &&            !oldmap.isempty ()) {Totallist.addall (OLDMAP);        Pagehelper.startpage (page, pagesize-oldmap.size ());        }else{pagehelper.startpage (page, pageSize);        } list = Invoicemapper.invoicelist (Parammap);         if (null! = List &&!list.isempty ()) {Totallist.addall (list);   Amountformatutil.formatamount (Totallist, "Inv_amount");        }//Create return value object pageinfo<list<map>> PageInfo = new PageInfo (totallist);        pageinfo<list<map>> pageInfo1 = new PageInfo (OLDMAP);        pageinfo<list<map>> PageInfo2 = new PageInfo (List);        Result.put ("InvoiceData", Pageinfo.getlist ());        Result.put ("Number", Pageinfo1.gettotal () +pageinfo2.gettotal ());    return result; }

Find the first SQL every time you page a query will find all:

Finally, in another blog, I found:

Finally, modify in the settings:

@Bean public    Pagehelper pagehelper () {        log.info ("Registered MyBatis page plug-in Pagehelper");        Pagehelper pagehelper = new Pagehelper ();        Properties P = new properties ();        P.setproperty ("Offsetaspagenum", "true");        P.setproperty ("Rowboundswithcount", "true");        P.setproperty ("reasonable", "false");//Before this is true        pagehelper.setproperties (p);        return pagehelper;    }

So my query data, the first SQL total only three data, when the number of pages more than the current total number of pages will be queried the first page, that is, parameter paging rationalization, if the following brothers have encountered similar problems, hope to be able to help.

Pagehelper Multiple SQL Paging

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.