I have a tree structure of /content/yyyy/mm/dd where article pages reside under the dd directory.
If I execute this query in crx/de:
you can see it returns 196 nodes/pages. If I execute the query using this block of code:
QueryManager queryManager;
QueryResult articleCollection;
queryManager = session.getWorkspace().getQueryManager();
javax.jcr.query.Query query;
query = queryManager.createQuery(sqlStatement, javax.jcr.query.Query.JCR_SQL2);
articleCollection = query.execute();
return articleCollection;
then -1 articles are returned. However, if I move all the articles to a single day, say 2022/9/1 and specify '/content/2022/9/1' as the root then the Java query will return 196 results.
It appears the Java version of the query isn't actually descending and picking up child nodes. Am I missing something?
Solved! Go to Solution.
Views
Replies
Total Likes
Well I feel a little foolish, getSize() returns -1 but the collection is actually complete. Thanks for your help
There is not difference.
The JCR Query API is lazy; that means that the result set is only resolved when it's requested. In other words: It is not known upfront how many results you have until you have iterated through the complete result set, because the resolution is a complex operation, and doing all that work just to get the size is a massive overhead.
CRX DE does that for you (and it can be really slow because of that!), but not the raw JCR API.
Well I feel a little foolish, getSize() returns -1 but the collection is actually complete. Thanks for your help
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies