I have seen a couple posts here related to a similar issue, where JCR-SQL2 query returns 3 results in CRXDE Query Tool but 0 results in OSGI.
Here's my code:
String query = "SELECT DISTINCT page.[jcr:path] FROM [cq:Page] AS page...";
Session session = resourceResolver.adaptTo(Session.class);
QueryManager queryManager = session.getWorkspace().getQueryManager();
Query query = queryManager.createQuery(query, Query.JCR_SQL2);
QueryResult queryResult = query.execute();
String mycontent = new String();
if (queryResult.getNodes() != null) {
NodeIterator nodeIterator = queryResult.getNodes();
while (nodeIterator.hasNext()) {
Node node = nodeIterator.nextNode();
String path = node.getPath();
mycontent += path;
}
}
The variable mycontent returns empty. Am I missing something? I tried to look into the queryResult but there's no return values inside. When I use breakpoint, it shows nodeIterator.hasNext() return false..