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)[EMAIL PROTECTED]: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 = ...;
rootNode.getNode("lgw:root/companies/Lycos");
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.
regards
marcel