利用jpa進行分頁查詢

1. jpa ,若是隻想用jpa查詢固定條數的數據,能夠這麼操做java

User findFirstByOrderByLastnameAsc();

User findTopByOrderByAgeDesc();

Page<User> queryFirst10ByLastname(String lastname, Pageable pageable);

Slice<User> findTop3ByLastname(String lastname, Pageable pageable);

List<User> findFirst10ByLastname(String lastname, Sort sort);

List<User> findTop10ByLastname(String lastname, Pageable pageable);

 

List<User> findAllByUserNameEquals(String userName,Pageable pageable);

調用的時候code

userRepository.findAllByUserNameEquals("關關", PageRequest.of(0,10)); //其中0爲page,10爲size

3. jpa使用語法:it

相關文章
相關標籤/搜索