zoukankan      html  css  js  c++  java
  • MyBatis(3.2.3)

    Sometimes, we may need to work with huge volumes of data, such as with tables with millions of records. Loading all these records may not be possible due to memory constraints, or we may need only a fragment of data. Typically in web applications, pagination is used to display large volumes of data in a page-by-page style.

    MyBatis can load table data page by page using RowBounds. The RowBounds object can be constructed using the offset and limit parameters. The parameter offset refers to the starting position and limit refers to the number of records.

    Suppose if you want to load and display 25 student records per page, you can use the following query:

    <select id="findAllStudents" resultMap="StudentResult">
        select * from Students
    </select>

    Then, you can load the first page (first 25 records) as follows:

    int offset =0 , limit =25;
    RowBounds rowBounds = new RowBounds(offset, limit);
    List<Student> = studentMapper.getStudents(rowBounds);

    To display the second page, use offset=25 and limit=25; for the third page, use offset=50 and limit=25.

  • 相关阅读:
    JZOJ6096 森林
    HIT暑期集训 二分图匹配
    HIT暑期集训 网络流
    HIT暑期集训 tarjan,dfs序
    HIT暑期集训 图论基础
    HIT暑期集训 AC自动机
    HIT第二周 周测补题
    HIT暑期集训 字符串
    HIT暑期集训 动态规划
    HIT暑期集训 平衡树
  • 原文地址:https://www.cnblogs.com/huey/p/5231759.html
Copyright © 2011-2022 走看看