public interface UserRepository extends JpaRepository<User, Long> {
@Query(value = "SELECT id AS USER_ID, name AS NAME FROM USERS ORDER BY ?#{#pageable} ",
countQuery = "SELECT count(id) FROM USERS ORDER BY ?#{#pageable}",
nativeQuery = true)
Page<User> findAll(Pageable pageable);
}
/users --> give me 20 records
/users?sort=name,desc --> give me 20 records sorted by name
/users?sort=userId,desc --> throws the error USERID not valid identifier
Я не знаю, почему userId не конвертируется в USER_ID в nativeQuery