You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by avim <av...@timetoknow.org> on 2007/02/19 13:29:24 UTC

many to many relations/flexible hierarchies/references

I have many to many relations represented in JCR by multi-valued REFERENCE
properties and usually the order is crucial. I've found out that jcr:deref
doesn't maintain the order of (it's input) multi-valued REFERENCE properties
- related to xml document order...
The typical query is:
//*[@prop1='value1']/jcr:deref(@references,'*')[@prop2='value2' or
@prop2='value3']
The question is how do I something like that without jcr:deref?
How do I configure/disable document order behaviour? will it help?
This also brings up the question what about relationship specific data?
Any best practices for JCR "connection objects" like connection tables in
RDBMS? and for  many to many relations in general? assuming that flexible
hierarchies are required?

-- 
View this message in context: http://www.nabble.com/many-to-many-relations-flexible-hierarchies-references-tf3252566.html#a9041516
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: [JCR Browser] many to many relations/flexible hierarchies/references

Posted by avim <av...@timetoknow.org>.
The order of multi-valued properties IS restored within Jackrabbit, but
jcr:deref doesn't respect that order...
so you CAN derefernce manually without losing the order.
The problem is I'm using query based ORM(OCM) strategy (like grafitto jcr
mapping), and your solution seems to be pretty messy to implement.
How exactly do you control the order within the orderable child nodes?

Brian Thompson-5 wrote:
> 
> On 2/26/07, avim <av...@timetoknow.org> wrote:
>>
>>
>> What is the score in this case?
>> Anyway I don't think it will give me the desired order, and there is a
>> need
>> for kind of predicates/relations with extra data/connection objects
>> anyway.
>> Any advice/best practices?
>>
> 
> 
> In my application, I had one instance where I needed to keep track of an
> ordered list of references to other nodes in the repository.  At first
> glance, using a multi-valued property on my tracker node seemed like the
> best idea.  Since that doesn't guarantee any sort of order, I resorted to
> orderable child nodes, each one of which has a property that refers to the
> desired node.  It's a little less elegant, but until Jackrabbit supports
> orderable multi-valued properties, it will have to do.
> 
> -Brian
> 
> 

-- 
View this message in context: http://www.nabble.com/many-to-many-relations-flexible-hierarchies-references-tf3252566.html#a9249663
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: [JCR Browser] many to many relations/flexible hierarchies/references

Posted by Brian Thompson <el...@gmail.com>.
Oops.  I thought I read somewhere that multi-value properties don't
necessarily maintain their order.  I can't seem to find the place where I
read that, though, so it looks like I just had the wrong idea :(

Thanks for the correction, though.

-Brian



On 2/26/07, Stefan Guggisberg <st...@gmail.com> wrote:
>
> On 2/26/07, Brian Thompson <el...@gmail.com> wrote:
> > On 2/26/07, avim <av...@timetoknow.org> wrote:
> > >
> > >
> > > What is the score in this case?
> > > Anyway I don't think it will give me the desired order, and there is a
> > > need
> > > for kind of predicates/relations with extra data/connection objects
> > > anyway.
> > > Any advice/best practices?
> > >
> >
> >
> > In my application, I had one instance where I needed to keep track of an
> > ordered list of references to other nodes in the repository.  At first
> > glance, using a multi-valued property on my tracker node seemed like the
> > best idea.  Since that doesn't guarantee any sort of order, I resorted
> to
> > orderable child nodes, each one of which has a property that refers to
> the
> > desired node.  It's a little less elegant, but until Jackrabbit supports
> > orderable multi-valued properties, it will have to do.
>
> for the sake of correctness: jackrabbit *does* support orderable
> multi-valued
> properties. in fact all multi-valued properties do persist the order
> of their values.
>
> cheers
> stefan
>
> >
> > -Brian
> >
>

Re: [JCR Browser] many to many relations/flexible hierarchies/references

Posted by Stefan Guggisberg <st...@gmail.com>.
On 2/26/07, Brian Thompson <el...@gmail.com> wrote:
> On 2/26/07, avim <av...@timetoknow.org> wrote:
> >
> >
> > What is the score in this case?
> > Anyway I don't think it will give me the desired order, and there is a
> > need
> > for kind of predicates/relations with extra data/connection objects
> > anyway.
> > Any advice/best practices?
> >
>
>
> In my application, I had one instance where I needed to keep track of an
> ordered list of references to other nodes in the repository.  At first
> glance, using a multi-valued property on my tracker node seemed like the
> best idea.  Since that doesn't guarantee any sort of order, I resorted to
> orderable child nodes, each one of which has a property that refers to the
> desired node.  It's a little less elegant, but until Jackrabbit supports
> orderable multi-valued properties, it will have to do.

for the sake of correctness: jackrabbit *does* support orderable multi-valued
properties. in fact all multi-valued properties do persist the order
of their values.

cheers
stefan

>
> -Brian
>

Re: [JCR Browser] many to many relations/flexible hierarchies/references

Posted by Brian Thompson <el...@gmail.com>.
On 2/26/07, avim <av...@timetoknow.org> wrote:
>
>
> What is the score in this case?
> Anyway I don't think it will give me the desired order, and there is a
> need
> for kind of predicates/relations with extra data/connection objects
> anyway.
> Any advice/best practices?
>


In my application, I had one instance where I needed to keep track of an
ordered list of references to other nodes in the repository.  At first
glance, using a multi-valued property on my tracker node seemed like the
best idea.  Since that doesn't guarantee any sort of order, I resorted to
orderable child nodes, each one of which has a property that refers to the
desired node.  It's a little less elegant, but until Jackrabbit supports
orderable multi-valued properties, it will have to do.

-Brian

Re: [JCR Browser] many to many relations/flexible hierarchies/references

Posted by avim <av...@timetoknow.org>.
What is the score in this case?
Anyway I don't think it will give me the desired order, and there is a need
for kind of predicates/relations with extra data/connection objects anyway.
Any advice/best practices?

Marcel Reutegger wrote:
> 
> avim wrote:
>> I have many to many relations represented in JCR by multi-valued
>> REFERENCE
>> properties and usually the order is crucial. I've found out that
>> jcr:deref
>> doesn't maintain the order of (it's input) multi-valued REFERENCE
>> properties
>> - related to xml document order...
>> The typical query is:
>> //*[@prop1='value1']/jcr:deref(@references,'*')[@prop2='value2' or
>> @prop2='value3']
>> The question is how do I something like that without jcr:deref?
> 
> you could do an initial search for [@prop2='value2' or @prop2='value3']
> and then 
> manually check if one of the referencing nodes has a [@prop1='value1'].
> 
> or you could do it the other way round and search for [@prop1='value1' and 
> @references] and then dereference manually the result nodes and check
> @prop2.
> 
>> How do I configure/disable document order behaviour?
> 
> you have to set the parameter respectDocumentOrder to false in the
> SearchIndex 
> configuration.
> 
>> will it help?
> 
> if respectDocumentOrder is set to false, the result nodes are ordered by
> score.
> 
> regards
>   marcel
> 
> 

-- 
View this message in context: http://www.nabble.com/many-to-many-relations-flexible-hierarchies-references-tf3252566.html#a9158475
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: many to many relations/flexible hierarchies/references

Posted by Marcel Reutegger <ma...@gmx.net>.
avim wrote:
> I have many to many relations represented in JCR by multi-valued REFERENCE
> properties and usually the order is crucial. I've found out that jcr:deref
> doesn't maintain the order of (it's input) multi-valued REFERENCE properties
> - related to xml document order...
> The typical query is:
> //*[@prop1='value1']/jcr:deref(@references,'*')[@prop2='value2' or
> @prop2='value3']
> The question is how do I something like that without jcr:deref?

you could do an initial search for [@prop2='value2' or @prop2='value3'] and then 
manually check if one of the referencing nodes has a [@prop1='value1'].

or you could do it the other way round and search for [@prop1='value1' and 
@references] and then dereference manually the result nodes and check @prop2.

> How do I configure/disable document order behaviour?

you have to set the parameter respectDocumentOrder to false in the SearchIndex 
configuration.

> will it help?

if respectDocumentOrder is set to false, the result nodes are ordered by score.

regards
  marcel