summary :
When you want to directly retrieve only qualified records in the database language , When there is no need to process it through the program ,SQL Statement paging technology was born , adopt SQL Statement paging can be realized only by changing the query statement , Namely in SQL Add after statement limit Paging statement .
put in plain language MySql Pagination is supported through limit Sub statement .
limit The usage of the statement is as follows :
LIMIT [office,] rows( among office Refers to the offset relative to the first row ( First behavior 0),rows Refers to the number of records returned )
General usage :
The student form is used , Persistence Student class , Try using annotation .
student surface :
Student.java
StudentMapper.xml
StudentService.java
StudentServiceImpl.java
AppTest.java
test result :
It did return 5 Data bar
three . Use paging parameters RowBound
Mybatis The framework not only supports paging , It also has a built-in class that specializes in paging ——rowBounds.
modify :
StudentMapper.xml
@Select("SELECT * from student") List<Student> getStudentByPage2(RowBounds
rowBounds);
AppTest.java
RowBounds It's a package offset and limit Simple class of , Just these two steps can easily achieve the paging effect .
Technology