How can i add an expression to jcr sql2 query?

155 Views Asked by At

I have query

SELECT * 
FROM [cq:ReplicationStatus] AS node 
WHERE (ISDESCENDANTNODE(node,'/home/users/we-retail') 
  AND node.[rep:authorizableId] = ${userId}) 

and I have a function

public HashMap<String, Object> getInformation(Integer userId) throws IOException, RepositoryException 
{
     ... 
}

where I execute my query. But it does not work, because ${userId} is a string not an expression. I also tried

SELECT * 
FROM [cq:ReplicationStatus] AS node 
WHERE (ISDESCENDANTNODE(node,'/home/users/A') 
  AND node.[rep:authorizableId] = '\"+userId+\"')"

Where is my mistake?

1

There are 1 best solutions below

0
Reporter On

I'm not sure if I understand you right:

public HashMap<String, Object> getInformation(Integer userId) throws 
       IOException, RepositoryException 
{
     String sqlQueryStr = "SELECT * FROM [cq:ReplicationStatus] AS node
     WHERE (ISDESCENDANTNODE(node,'/home/users/A') AND 
     node.[rep:authorizableId] = '"+userId+"')";
     ... 
}

should work.