You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Anton Gavazuk <an...@gmail.com> on 2008/09/11 03:41:08 UTC

Problems with XPath query - no result

HI all,
get stuck with a problem

my repository looks like
/jcr:root/
   -----A/nt:unstructured
        ------B/nt:unstructured
               -file / nt:file
                 ....
               -file

the problem is that queries like

//element(*, nt:file)
/jcr:root//element(*, nt:file)
/jcr:root/A/B/element(*, nt:file)

dont return result at all

but query below works fine
/jcr:root/A/B

And the most strange thing that ALL queries work fine when I'm testing
them in JCR Explorer

Could you give me advice what is the issue?

Re: Problems with XPath query - no result

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Mon, Sep 15, 2008 at 12:22 PM, Anton Gavazuk <an...@gmail.com> wrote:
> Sorry everyone for disturbing - Spec is cool source for ideas :)

No problem, sorry for the delayed response. :-) I guess nobody had an
idea what could be wrong with your setup until you mentioned that
you're using transactions...

> As I did everything (node creation and querying) in one transaction so
> even session.save() didnt persist changes in repository.
>
> But I'm still confused - query engine doesnt look on changes which
> exist only in memory?

Yes, this explains the behavior you're seeing. Jackrabbit only updates
the query index once the changes to the repository are made available
to all clients. And since a transaction prevents other clients to from
seeing your changes until you commit them, neither will the query
index be updated until the transaction is committed.

The JCR spec is intentionally vague on when and how changes in the
repository are reflected in the query index. JSR 283 will explain the
potential behavior better, but still leaves it up to the repository
implementation to decide how to implement the query index.

BR,

Jukka Zitting

Re: Problems with XPath query - no result

Posted by Anton Gavazuk <an...@gmail.com>.
Sorry everyone for disturbing - Spec is cool source for ideas :)

As I did everything (node creation and querying) in one transaction so
even session.save() didnt persist changes in repository.

But I'm still confused - query engine doesnt look on changes which
exist only in memory?


My situation was:

start Transaction

node creation

session.save() (changes are still only in memory)

run query - empty result

commit transaction (changes are applied to store)


2008/9/12 Anton Gavazuk <an...@gmail.com>:
> Hi Guys,
>
> please, do you have an idea why its behaving in such way?
>
> 2008/9/11 Anton Gavazuk <an...@gmail.com>:
>> HI all,
>> get stuck with a problem
>>
>> my repository looks like
>> /jcr:root/
>>   -----A/nt:unstructured
>>        ------B/nt:unstructured
>>               -file / nt:file
>>                 ....
>>               -file
>>
>> the problem is that queries like
>>
>> //element(*, nt:file)
>> /jcr:root//element(*, nt:file)
>> /jcr:root/A/B/element(*, nt:file)
>>
>> dont return result at all
>>
>> but query below works fine
>> /jcr:root/A/B
>>
>> And the most strange thing that ALL queries work fine when I'm testing
>> them in JCR Explorer
>>
>> Could you give me advice what is the issue?
>>
>

Re: Problems with XPath query - no result

Posted by Anton Gavazuk <an...@gmail.com>.
Hi Guys,

please, do you have an idea why its behaving in such way?

2008/9/11 Anton Gavazuk <an...@gmail.com>:
> HI all,
> get stuck with a problem
>
> my repository looks like
> /jcr:root/
>   -----A/nt:unstructured
>        ------B/nt:unstructured
>               -file / nt:file
>                 ....
>               -file
>
> the problem is that queries like
>
> //element(*, nt:file)
> /jcr:root//element(*, nt:file)
> /jcr:root/A/B/element(*, nt:file)
>
> dont return result at all
>
> but query below works fine
> /jcr:root/A/B
>
> And the most strange thing that ALL queries work fine when I'm testing
> them in JCR Explorer
>
> Could you give me advice what is the issue?
>