mybatis扩展-查询结果排序的两种方式

1.使用PageHelper排序(Pagehelper的版本需在5.1.2及以上)

<!– https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper –>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.2</version>
</dependency>

PageHelper.startPage(pageNum , pageSize);PageHelper.orderBy(“A B”);
其中A为排序依据的字段名,B为排序规律,desc为降序,asc为升序

或者一步到位

String orderBy=”字段名 排序规律”;

PageHelper.startPage(pageNum, pageSize, orderBy);

2.使用Mybatis排序

XXXExample example = new XXXExample();

example.setOrderByClause(“字段名1 ASC/DESC,字段名2 ASC/DESC,…”);
———————

来自:https://blog.csdn.net/kalnon/article/details/79559627

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments