记一个Spring Data JPA自定义分页查询BUG

官方给出的自定义分页查询的示例是这样的:

1
2
3
4
5
6
public interface UserRepository extends JpaRepository<User, Long> {
@Query(value = "SELECT * FROM USERS WHERE LASTNAME = ?1",
countQuery = "SELECT count(*) FROM USERS WHERE LASTNAME = ?1",
nativeQuery = true)
Page<User> findByLastname(String lastname, Pageable pageable);
}
阅读更多