You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Nicolas <nt...@gmail.com> on 2006/10/30 21:01:18 UTC

Question about root node children?

Hi,

As you know, I am still fairly new to Jackrabbit and its internals. I think
there is something I didn't understand correctly. Can you please help me?

I am trying to fetch all direct children of the root node from a repository
with 3 nodes I have put in. When I write root.getChildNodeEntries(); I have
a List with 170 elements in it!  When I display their QName, there are only
5 differnent QNames as expected (my 3 nodes + root + jcr:system).

What am I doing wrong please?

BR,
Nico
my blog! http://www.deviant-abstraction.net !!

Re: Question about root node children?

Posted by Nicolas <nt...@gmail.com>.
Hi Jukka,

Thanks, you are totally right.

(for the little story, it comes from a temporary unit test.)

Nico

On 10/31/06, Jukka Zitting <ju...@gmail.com> wrote:
>
> Hi,
>
> On 10/31/06, Nicolas <nt...@gmail.com> wrote:
> > Actually they have different names, but the same name sibling is a use
> case
> > I should be taking care of.
> >
> > Do you have an idea why with same name sibling this behaviour happens?
>
> You've probably run code like the following a few times over:
>
>     Session session = ...;
>     Node root = session.getRootNode();
>     root.addNode("A");
>     root.addNode("B");
>     root.addNode("C");
>     session.save();
>
> When run multiple times, this results in a repository like this:
>
>    /
>    /jcr:system
>    /A[1]
>    /A[2]
>    /A[...]
>    /B[1]
>    /B[2]
>    /B[...]
>    /C[1]
>    /C[2]
>    /C[...]
>
> BR,
>
> Jukka Zitting
>



-- 
a+
Nico
my blog! http://www.deviant-abstraction.net !!

Re: Question about root node children?

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

On 10/31/06, Nicolas <nt...@gmail.com> wrote:
> Actually they have different names, but the same name sibling is a use case
> I should be taking care of.
>
> Do you have an idea why with same name sibling this behaviour happens?

You've probably run code like the following a few times over:

    Session session = ...;
    Node root = session.getRootNode();
    root.addNode("A");
    root.addNode("B");
    root.addNode("C");
    session.save();

When run multiple times, this results in a repository like this:

   /
   /jcr:system
   /A[1]
   /A[2]
   /A[...]
   /B[1]
   /B[2]
   /B[...]
   /C[1]
   /C[2]
   /C[...]

BR,

Jukka Zitting

Re: Question about root node children?

Posted by Nicolas <nt...@gmail.com>.
Actually they have different names, but the same name sibling is a use case
I should be taking care of.

Do you have an idea why with same name sibling this behaviour happens?

BR
Nico
my blog! http://www.deviant-abstraction.net !!

On 10/31/06, Marcel Reutegger <ma...@gmx.net> wrote:
>
> just a wild guess, you are using same name siblings?
>
> regards
>   marcel
>
>
>

Re: Question about root node children?

Posted by Marcel Reutegger <ma...@gmx.net>.
just a wild guess, you are using same name siblings?

regards
  marcel

Nicolas wrote:
> Hi,
> 
> As you know, I am still fairly new to Jackrabbit and its internals. I think
> there is something I didn't understand correctly. Can you please help me?
> 
> I am trying to fetch all direct children of the root node from a repository
> with 3 nodes I have put in. When I write root.getChildNodeEntries(); I have
> a List with 170 elements in it!  When I display their QName, there are only
> 5 differnent QNames as expected (my 3 nodes + root + jcr:system).
> 
> What am I doing wrong please?
> 
> BR,
> Nico
> my blog! http://www.deviant-abstraction.net !!
> 


Re: Question about root node children?

Posted by Nicolas <nt...@gmail.com>.
Hi Szymon,

Rereading my email, there is something important I forgot to write: the
snippet of code is the following:

itemOps = new a BatchedItemOperations(...);
NodeState root = itemOps.getNodeState(nodeInfo.getId());
root.getChildNodeEntries();

As you can see root is not an instance of Node but of NodeState. Maybe it
would help you to explain things better?

Nico
my blog! http://www.deviant-abstraction.net !!

On 10/31/06, Szymon Kuzniak <sk...@wp.pl> wrote:

> if You would like to fetch children, I think the better way will be to
> use getNodes() method on root node, because getChildNodeEntries()
> returns list of node entries, not nodes. This will return NodeIterator,
> so You will be able to iterate over all children.
> Hope this will help.
>
> Regards
> Simon
>
>
> --
> Szymon Kuzniak
> szymon.kuzniak( at )cognifide.com
> Skype: skuzniak
> Cognifide Poland
> Poznan
>

Re: Question about root node children?

Posted by Szymon Kuzniak <sk...@wp.pl>.
Nicolas napisal(a):
> Hi,
> 
> As you know, I am still fairly new to Jackrabbit and its internals. I think
> there is something I didn't understand correctly. Can you please help me?
> 
> I am trying to fetch all direct children of the root node from a repository
> with 3 nodes I have put in. When I write root.getChildNodeEntries(); I have
> a List with 170 elements in it!  When I display their QName, there are only
> 5 differnent QNames as expected (my 3 nodes + root + jcr:system).
> 
> What am I doing wrong please?

if You would like to fetch children, I think the better way will be to 
use getNodes() method on root node, because getChildNodeEntries() 
returns list of node entries, not nodes. This will return NodeIterator, 
so You will be able to iterate over all children.
Hope this will help.

Regards
Simon


-- 
Szymon Kuzniak
szymon.kuzniak( at )cognifide.com
Skype: skuzniak
Cognifide Poland
Poznan