5

I'm using the following JCR-SQL2 Query to retrieve some files from jackrabbit repository

    SELECT id FROM [nt:file]
  WHERE ISDESCENDANTNODE([/repo/cms]) 

How can I use pagination in jackrabbit to retrieve only a limit number of files.

I mean the COUNT in MS-SQL or LIMIT in MySQL

Ammar Bozorgvar
  • 1,230
  • 19
  • 30

1 Answers1

11

How about this:

Query query = queryManager.createQuery(queryString, Query.SQL);
QueryImpl q = (QueryImpl) query;
q.setLimit(10);
q.setOffset(10); // Start from the 10:th file
QueryResult result = q.execute();
Per
  • 636
  • 5
  • 8
  • it seems that jackrabbit did not implement the setLimit() and setOffset() methods and i get this error : Caused by: java.lang.RuntimeException: TODO: JCRRMI-26 .... which means this method will be implemented later – Ammar Bozorgvar Sep 17 '11 at 08:05
  • 1
    @Ammar: AFAICS you access Jackrabbit through RMI. Jackrabbit itself does support the setLimit() and setOffset() method. The error you are getting is from the RMI layer which does not (yet) implement these methods. – michid Sep 20 '11 at 10:31
  • This is not enough for pagination, what about total count? – khoi nguyen Dec 07 '17 at 14:18