Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

JCR-SQL2 query return no results in OSGI but returns results in crxde query tool.

Avatar

Employee

Hi,

String sqlQuery = "SELECT * FROM [dam:Asset] AS asset " +
"WHERE ISDESCENDANTNODE(asset, '/content/dam') " +
"AND asset.[jcr:path] NOT LIKE '/content/dam/archive/%' " +
"AND asset.[jcr:content/metadata/productdata/samsExpirationDate] IS NOT NULL " +
"AND asset.[jcr:content/metadata/productdata/samsExpirationDate] < '" + currentDateStr + "'";

QueryManager queryManager = session.getWorkspace().getQueryManager();
Query query = queryManager.createQuery(sqlQuery, Query.JCR_SQL2);
query.setLimit(limit);
query.setOffset(0);
QueryResult result = query.execute();

Keerthana_H_N_0-1755695484027.png

query is working in local but not in dev cloud. Working in dev crxde as well. I have given the read, write permission for the given path. updated the index as well. Still the query is not getting results. Please let me know what might be the issue.

Thank you.

 

 

7 Replies

Avatar

Level 6

@Keerthana_H_N Could you explain the issue a little more? query is working in local but not in dev cloud means do you see any error or you are getting results for same query?

Avatar

Employee

Query is failing to give results in dev cloud. There's no error just query results are 0. And same query is working when deployed to local. When I just run the query in dev crxde tools able to get the result. Via code trying to run failed get the results.

Avatar

Community Advisor

Hi @Keerthana_H_N 
How did you get the session? Is it a subservice session or user session? If subservice session then how and How did you set the permission for service user?

Arun Patidar

AEM LinksLinkedIn

Avatar

Employee

get seesion from service user and in the service user I have provided the read and write permission for /content/dam folder

Avatar

Community Advisor

Hi @Keerthana_H_N 

Could you please check logs. If it is working on local but not in dev with same code then issue could be with permission or subservice configuration.

Arun Patidar

AEM LinksLinkedIn

Avatar

Level 9

Check out this helpful tutorial to ensure everything is in the right place: https://experienceleague.adobe.com/en/docs/experience-manager-learn/cloud-service/developing/advance... 

 

Avatar

Administrator

@Keerthana_H_N just checking in! Were you able to get this resolved? If one of the replies above helped—whether it completely solved the issue or simply pointed you in the right direction—marking it as accepted can make it much easier for others with the same question to find a solution. And if you found a different way to fix it, sharing your approach would be a great contribution to the community. Your follow-up not only helps close the loop but also ensures others benefit from your experience. Thanks so much for being part of the conversation!



Kautuk Sahni