0

I use spring boot with spring data jdbc.

I search to get x number of record

In a interface I have

@Query("select u from user where status=1");
List<User> findUser();

Is it possible in spring data jdbc?

robert trudel
  • 5,283
  • 17
  • 72
  • 124

1 Answers1

0

There is currently no build in mechanism to do that, so you can't just add a Pageable as an argument to achieve this.

But you can incorporate the limit in the query. Note that the syntax varies between databases. The following example should work for MySql

@Query("select u from user where status=1 ORDER BY u LIMIT :rows)
List<User> findUser(int rows);
Jens Schauder
  • 77,657
  • 34
  • 181
  • 348