You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "Martin Zdila (JIRA)" <ji...@apache.org> on 2008/01/18 09:14:42 UTC
[jira] Reopened: (JCR-1323) When using QueryImpl.setLimit() and
QueryImpl.setOffset(), then NodeIterator.getSize() reports wrong size
[ https://issues.apache.org/jira/browse/JCR-1323?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Martin Zdila reopened JCR-1323:
-------------------------------
I think you didn't understand me completely. If I have 45 nodes, offset is 40 and limit is 20 (ie I am on the last page), then NodeIterator.getSize() should report 5 and not 20.
final Query query = session.getWorkspace().getQueryManager().createQuery(queryString, Query.XPATH);
((QueryImpl) query).setLimit(limit);
((QueryImpl) query).setOffset(offset > 0 ? offset - 1 : offset);
NodeIterator ni = queryResult.getNodes();
System.out.println(ni.getSize()); // will print 20 and not 5 as expected
int i;
for (i = 0; ni.hasNext(); i++) {
ni.nextNode();
}
System.out.println(i); // will print 5
Now I must use workaround:
final long totalSize = ((QueryResultImpl) queryResult).getTotalSize();
final long size = Math.min(ni.getSize(), totalSize - offset + 1);
If I am wrong again, then I apologize in advance :-)
> When using QueryImpl.setLimit() and QueryImpl.setOffset(), then NodeIterator.getSize() reports wrong size
> ---------------------------------------------------------------------------------------------------------
>
> Key: JCR-1323
> URL: https://issues.apache.org/jira/browse/JCR-1323
> Project: Jackrabbit
> Issue Type: Bug
> Affects Versions: 1.4
> Environment: Linux, Java 6
> Reporter: Martin Zdila
> Assignee: Christoph Kiehl
>
> When using QueryImpl.setLimit() and QueryImpl.setOffset(), then NodeIterator.getSize() reports wrong size. Returned size seems to be allways the same as the limit.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.