Hi,
I am running an INNER JOIN query(javax.jcr.query.Query). I am getting an exception:
javax.jcr.RepositoryException: This query result contains more than one selector .
However when I am running this query directly in CRXDE it runs fine. Any idea.
Sample query:
SELECT parent.* FROM [cq:Page] AS parent INNER JOIN [nt:base] AS child ON ISCHILDNODE(child,parent) WHERE ISDESCENDANTNODE(parent, '/content')
and NAME(child) = 'status'AND child.[cq:template] = '/libs/cq/personalization/templates/campaign'
Regards,
Shallu Rohilla
Solved! Go to Solution.
Views
Replies
Total Likes
Instead of using query.execute().getNodes() method use the following snippet to get the iterator-
final QueryResult result = query.execute();final RowIterator iterator = result.getRows(); while (iterator.hasNext()) { final Row row = iterator.nextRow(); Node node = session.getNode(row.getPath("parent")); }
Views
Replies
Total Likes
If you are using JCR API to execute this SQL2 query then you will have to use a different method to get the node returned by the query.
//Normal SQL2 query execution final RowIterator iterator = result.getRows(); while (iterator.hasNext()) { final Row row = iterator.nextRow(); Node node = row.getNode(); } //for multiple selectors you need to use the following method final RowIterator iterator = result.getRows(); while (iterator.hasNext()) { final Row row = iterator.nextRow(); Node node = session.getNode(row.getPath(“parent”)); }
Reference - https://issues.apache.org/jira/browse/JCR-3089
Views
Replies
Total Likes
Actually I am getting error on calling query.execute method itself(see the underlined code).
QueryManager queryManager = session.getWorkspace().getQueryManager();
Query query = queryManager.createQuery(statement, Query.JCR_SQL2);
query.setLimit(nodeSearchCriteria.getLimit());
query.setOffset(nodeSearchCriteria.getStart());
final NodeIterator iterator = query.execute().getNodes();
Regards,
Shallu Rohilla
Views
Replies
Total Likes
Instead of using query.execute().getNodes() method use the following snippet to get the iterator-
final QueryResult result = query.execute();final RowIterator iterator = result.getRows(); while (iterator.hasNext()) { final Row row = iterator.nextRow(); Node node = session.getNode(row.getPath("parent")); }
Views
Replies
Total Likes
Thanks Kunal.That helps!!
Views
Replies
Total Likes
Hi Shallu,
Are you executing this query via OSGI service? If yes, Can you please share the code snippet.
Meanwhile please take a look at Community article on it @ https://helpx.adobe.com/experience-manager/using/querying-experience-manager-data-using1.html
Views
Replies
Total Likes