1. jpa ,如果只想用jpa查询固定条数的数据,可以这么操作

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);

调用的时候

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

3. jpa使用语法:

01-14 23:05