You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Charles Flond <cf...@jahia.com> on 2011/05/02 15:44:10 UTC
Keep nodes order with JCR-SQL2 queries
Hello,
I am currently trying to do the following scenario :
I have a node of type "jnt:contentList" named "maincontent" which is defined
as "orderable" in the JCR. Its path is "/sites/demo/home/maincontent/".
Under this node, I have several others nodes, ordered by myself (no
automatic sort on dates ...).
Now, I perform a JCR-SQL2 query like that : select * from [jnt:content] as
content where ISDESCENDANTNODE(content,'/sites/demo/home/maincontent/')
I retrieve my maincontent's subnodes, but I lost the order ! Is there a way
to keep it ?
To summarize :
The original list :
- mainContent
-- nodeA
-- nodeB
-- nodeE
-- nodeC
The list generated by the query :
-SQL2QueryTargetingMainContent
--nodeC
--nodeB
--nodeA
--nodeE
Thanks in advance for your help !
Charles
Re: Keep nodes order with JCR-SQL2 queries
Posted by Charles Flond <cf...@jahia.com>.
Hi Alex,
It works perfectly ! Thanks for your help.
Charles
On Mon, May 2, 2011 at 3:57 PM, Alexander Klimetschek <ak...@adobe.com>wrote:
> On 02.05.11 15:44, "Charles Flond" <cf...@jahia.com> wrote:
> >Now, I perform a JCR-SQL2 query like that : select * from [jnt:content] as
> >content where ISDESCENDANTNODE(content,'/sites/demo/home/maincontent/')
>
> Don't use a query for this, but the navigational access:
>
> session.getNode("/sites/demo/home/maincontent/").getNodes()
>
> This gives you the order, will be faster & more efficient than a query.
>
> Regards,
> Alex
>
> --
> Alexander Klimetschek
> Developer // Adobe (Day) // Berlin - Basel
>
>
>
>
>
Re: Keep nodes order with JCR-SQL2 queries
Posted by Alexander Klimetschek <ak...@adobe.com>.
On 02.05.11 15:44, "Charles Flond" <cf...@jahia.com> wrote:
>Now, I perform a JCR-SQL2 query like that : select * from [jnt:content] as
>content where ISDESCENDANTNODE(content,'/sites/demo/home/maincontent/')
Don't use a query for this, but the navigational access:
session.getNode("/sites/demo/home/maincontent/").getNodes()
This gives you the order, will be faster & more efficient than a query.
Regards,
Alex
--
Alexander Klimetschek
Developer // Adobe (Day) // Berlin - Basel