JCR-SQL2 query return no results in OSGI but returns results in crxde query tool. | Community
Skip to main content
Adobe Employee
August 20, 2025
Question

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

  • August 20, 2025
  • 3 replies
  • 501 views

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();



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.

 

 

3 replies

Uppari_Ramesh
Level 5
August 20, 2025

@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?

Adobe Employee
August 21, 2025

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.

arunpatidar
Community Advisor
Community Advisor
August 21, 2025

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
Adobe Employee
August 21, 2025

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

arunpatidar
Community Advisor
Community Advisor
August 21, 2025

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
kautuk_sahni
Community Manager
Community Manager
September 1, 2025

@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