I am using Jackrabbit and I am trying to query for an existing node which has a UUID. My code is shown below. The problem is that UUID for referenceNode is of the form "'90be246a-a17c-445e-a5ad-81b064de0bee'" and it seems that the XPATH engine used in Jackrabbit (Lucene) has problems dealing with hyphens.
If I run query2, everything is fine and referenceNode is printed. If I run query1 (with the UUID) inside Eclipse, nothing is returned. HOWEVER, if I run query1 inside Jackrabbit Viewer, the query runs fine.
It seems like I have to escape the hyphens in my queryString but I tried adding double-backslashes and I get the same result. What is the proper way to run queries against UUID's?
// Set up Nodes
rootNode = session.getRootNode();
Node referenceNode = rootNode.addNode("referenceNode");
Node referencingNode = rootNode.addNode("referencingNode");
referenceNode.addMixin("mix:referenceable");
referencingNode.setProperty("pointer", new ReferenceValue(referenceNode));
// Query
String uuid = referenceNode.getUUID();
QueryManager qm = ws.getQueryManager();
String queryString1 = "//*[@jcr:uuid='"+uuid+"']";
String queryString2 = "//referenceNode";
Query q = qm.createQuery(queryString1, Query.XPATH);
QueryResult result = q.execute();
NodeIterator it = result.getNodes();
while(it.hasNext()) {
Node node = it.nextNode();
System.out.println( node.getName());
}