Pagination query example

Paging query example


The use of Mybatis paging plugin PageHelper

public PageInfo<Goods> findByPage(Goods goods, Date createtimeStart, Date createtimeEnd, int pageNo, int pageSize) {
		PageHelper.startPage(pageNo, pageSize);
		Map m = ObjAnalysis.ConvertObjToMap(goods);
		List<Goods> goodsList = goodsMapper.getAll(m);

		PageInfo<Goods> PageInfGoods = new PageInfo<>(goodsList);

		return PageInfGoods;
	}


Sorting needs to implement

Mybatis, Order By sorting problem
http://blog.csdn.net/hu_zhiting/article/details/53026448

The difference between #{} and ${} of mybatis and the problem of order by injection
http://www.cnblogs .com/yanspecial/p/5659429.html




Spring Data JPA
Spring Data JPA: Pagination and Sorting
public Page<Blog> getEntryByParams(@RequestParam(value = "page", defaultValue = "0") Integer page,
        @RequestParam(value = "size", defaultValue = "15") Integer size) {
    Sort sort = new Sort(Direction.DESC, "id");
    Pageable pageable = new PageRequest(page, size, sort);
    return blogRepository.findAll(pageable);
}	



https://www.cnblogs.com/nicuty/p/6265303.html

http://blog.csdn.net/ie8848520/article/details/8161986

http://blog.csdn.net/dragonpeng2008/article/details/ 52252907


Get the Pageable object directly
@RequestMapping(value = "", method=RequestMethod.GET)
public Page<Blog> getEntryByPageable(@PageableDefault(value = 15, sort = { "id" }, direction = Sort.Direction.DESC)
    Pageable pageable) {
    return blogRepository.findAll(pageable);
}	



Sort by multiple fields
Order order2 = new Order(Direction.DESC, "age");  
Order order3 = new Order(Direction.ASC, "pgrade");  
Order order = new Order(Direction.DESC, "dnum");






Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326358942&siteId=291194637