jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Piotr Maj" ...@jcake.com>
Subject xpath, sql queries and nested properties
Date Fri, 30 Jun 2006 14:23:15 GMT
Hi,

I'm learning Jackrabbit and it absolutely rocks! I have however problems  
with
queries. I have the following structure (1 folder, 1 file with my mixed-in
description and annotations):

Node rootNode = session.getRootNode();
Node folder = rootNode.addNode("folder", "nt:folder");
Node file = folder.addNode("file", "nt:file");
Node content = file.addNode("jcr:content", "nt:resource");
content.addMixin("pm:annotable");
content.addMixin("pm:describable");
content.setProperty("jcr:data", new  
ByteArrayInputStream("TESTowy".getBytes()));
content.setProperty("jcr:mimeType", "text/plain");
content.setProperty("jcr:lastModified", Calendar.getInstance());
content.setProperty("pm:description", "To jest opis.");

Node annotation = content.addNode("pm:annotation", "pm:annotation");
annotation.setProperty("pm:content", "xxx");
annotation.setProperty("pm:creatorId", -1L);
annotation.setProperty("pm:creationDate", Calendar.getInstance());

annotation = content.addNode("pm:annotation", "pm:annotation");
annotation.setProperty("pm:content", "yyy");
annotation.setProperty("pm:creatorId", 55L);
annotation.setProperty("pm:creationDate", Calendar.getInstance());

session.save();


Now I try to perform some search:

QueryManager queryManager = session.getWorkspace().getQueryManager();
Query query = queryManager.createQuery("select * from nt:file where  
jcr:content.pm:description like 'To%'", Query.SQL);
QueryResult result = query.execute();
nodes = result.getNodes();
while (nodes.hasNext()) {
	Node node = nodes.nextNode();
       System.out.println(node.getName() + ": " + node.getPath());
}

And I get nothing. The question is: how should the query look like?

Another question is how should the query look like I wanted to find
all nt:resource nodes where one of nested pm:annotation.pm:content
property is equal to 'xxx'?

I'd appreciate if someone could write for me an SQL version of such
query as well as XPath one and explain to me why the query I used
is wrong?

Thank you in advance.

-- 
best wishes
piotr maj

Mime
View raw message