jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Frédéric Esnault <f...@legisway.com>
Subject RE: jcr:deref() in predicate
Date Fri, 22 Jun 2007 10:39:15 GMT
Thanks for the answer, but my question was : is there another way only using XPath? I should
have been clearer, sorry.

Frédéric Esnault

-----Message d'origine-----
De : Marcel Reutegger [mailto:marcel.reutegger@gmx.net] 
Envoyé : vendredi 22 juin 2007 12:28
À : dev@jackrabbit.apache.org
Objet : Re: jcr:deref() in predicate

Frédéric Esnault wrote:
> Thansk I will because if we don't have, how can we do this query.
> I want all contracts having as an internal contractor the company Lycos.
> Knowing that contractors are references in the contract type.
> I did /jcr:root/lgw:root/lgw:contracts/element(*, lgw:contractType)[jcr:deref(@lgw:internalContractor,
'lgw:contractorType')/@lgw:companyName = 'Lycos']
> Is there antoher way to make this query?

yes, there is. only search for the company node:

lgw:root//element(*, lgw:company)[@lgw:companyName = 'Lycos']

then use the API to get the references to the lycos company node:

Node lycosCompany = ...;
for (PropertyIterator it = lycosCompany.getReferences(); it.hasNext(); ) {
     Property p = it.nextProperty();
     if (p.getName().equals("lgw:internalContractor")) {
         Node contractType = p.getParent();
         // do something with this node

or even better, if there were no same name siblings you could directly address 
the lycos company by path:

Node rootNode = ...;

that way you don't even have to execute a query.

in contrast to databases you don't necessarily have to use joins to get to your 
content along references. the JCR API provides methods to do that much quicker 
than a query.


View raw message