jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcel Reutegger <marcel.reuteg...@gmx.net>
Subject Re: Finding a reference of reference
Date Fri, 09 Nov 2007 10:29:41 GMT
Kisu San wrote:
> I have nodes: Model, Variant, Codes, Topic.  Topic contains a xml file as
> property, codes are for a specific variant. That mean, Codes node has a
> property REFERENCE to Variant node. Variant Node in turn is specific for a
> Model. That is Variant has a property Reference to Model. 
> Now I need to find all the Codes  for a particular model.
> As far as I have seen the examples, I can resolve the reference using deref
> function up to one further node. I want to do something like 
> //element(*, CODES)[jcr:deref(@variant) ==> this gives variant node from
> which jcr:deref(@model = 'name')
> Have anyone implemented this kind of case. 
> 1. Is this possible with current version of Jackrabbit (1.3.3)

yes, but you should rather use API calls than a query:

Node myModel = ...
for (PropertyIterator modelRefs = myModel.getReferences(); modelRefs.hasNext(); ) {
   Node variant = modelRefs.nextProperty().getParent();
   for (PropertyIterator variantRefs = variant.getReferences(); 
variantRefs.hasNext(); ) {
     Node code = variantRefs.nextProperty().getParent();
     // do something with the code
     code ....

> 2. If yes, how to do this with XPath and Sql?

this is currently not possible. you would have execute two queries:

1) search for all variant nodes that have the reference property set to the 
model node in question
2) create a query that contains the uuids of the variant results from the 
previous query and search for code nodes that reference one of those uuids.

the API approach however performs better and is therefore the preferred one.


View raw message