Here is a sample solution:
Query is :
@Query("SELECT * FROM user LIMIT :limit OFFSET :offset")
User[] loadAllUsersByPage(int limit,int offset);
Here, it will list users based on limit and offset.
if `loadAllUsersByPage(2,0)` it will return the first 2 rows from the table.
if `loadAllUsersByPage(2,1)` it will return 2nd and 3rd rows from table.
but if `loadAllUsersByPage(-1,10)` then it will serve the first 10 rows from the table.
You can consider pagination to improve this problem.
**Query is** :
@Query("SELECT * FROM user LIMIT :limit OFFSET :offset")
User[] loadAllUsersByPage(int limit,int offset);
Here, it will give a list of user based on limit and offset.
if `loadAllUsersByPage(2,0)` it will return first 2 rows from table.
if `loadAllUsersByPage(2,1)` it will return 3rd and 4th rows from table.
but if `loadAllUsersByPage(-1,10)` then it will serve first 10 rows from table.
Thanks :)