Getting repository exception on executing query (inner join) in CQ5.6 | Community
Skip to main content
Level 4
October 16, 2015
Solved

Getting repository exception on executing query (inner join) in CQ5.6

  • October 16, 2015
  • 5 replies
  • 2699 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Kunal_Gaba_

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")); }

5 replies

edubey
Level 10
October 16, 2015

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

Level 4
October 16, 2015

Thanks Kunal.That helps!!

Kunal_Gaba_
Kunal_Gaba_Accepted solution
October 16, 2015

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")); }
Level 4
October 16, 2015

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

Kunal_Gaba_
October 16, 2015

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