PageHelper multi-table paging query. IO costs too much

the paging query for writing a single table through pagehelper was written happily. Now to write a winning bid (such as 2 tables)
if you write your own sql statement, you cannot use Criteria things. If you query the main table first and query another schedule (the same with collection), you will connect to the database very frequently. Is there any good solution code? Because I used to write the sql statement to associate the query to access the database once. Check the main table first. If the paging of the schedule is 10, it will be visited 10 times, and if the pagination is 20, it will be visited 20 times.

Mar.17,2021

according to your problem, the solution:

  1. Mybatis PageHelper supports winning queries, and you can use
  2. directly.
  3. if the subject wants to query a single table and query again, you might as well try this:

    1. query the first primary table to get the primary table data, and filter out the primary table id for standby.
    2. query the second table and add the main table id through the condition through the Criteria condition.
    3. connects the data from the two tables into a Bo class through java's own business logic.
Note
since the stored data set in Mybatis is stored by a TheadLocal, pay attention to the startPage method and get the PageList location, otherwise you may get the wrong data set
Menu