Return-Path: Delivered-To: apmail-jackrabbit-dev-archive@www.apache.org Received: (qmail 62852 invoked from network); 22 Jun 2007 10:28:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 Jun 2007 10:28:02 -0000 Received: (qmail 61883 invoked by uid 500); 22 Jun 2007 10:28:04 -0000 Delivered-To: apmail-jackrabbit-dev-archive@jackrabbit.apache.org Received: (qmail 61858 invoked by uid 500); 22 Jun 2007 10:28:04 -0000 Mailing-List: contact dev-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list dev@jackrabbit.apache.org Received: (qmail 61849 invoked by uid 99); 22 Jun 2007 10:28:04 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 Jun 2007 03:28:04 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of marcel.reutegger@gmx.net designates 213.165.64.20 as permitted sender) Received: from [213.165.64.20] (HELO mail.gmx.net) (213.165.64.20) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 22 Jun 2007 03:28:00 -0700 Received: (qmail invoked by alias); 22 Jun 2007 10:27:37 -0000 Received: from l2tp.day.com (EHLO [192.168.10.5]) [62.192.10.243] by mail.gmx.net (mp015) with SMTP; 22 Jun 2007 12:27:37 +0200 X-Authenticated: #894343 X-Provags-ID: V01U2FsdGVkX18mbawvjIkm6c5RsxvihvYDt4NcjzVO2cWzodFRCa nGQSPmUcQXVl4k Message-ID: <467BA418.2030402@gmx.net> Date: Fri, 22 Jun 2007 12:27:36 +0200 From: Marcel Reutegger User-Agent: Thunderbird 1.5.0.12 (Windows/20070509) MIME-Version: 1.0 To: dev@jackrabbit.apache.org Subject: Re: jcr:deref() in predicate References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Y-GMX-Trusted: 0 X-Virus-Checked: Checked by ClamAV on apache.org 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 = ...; 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