Fetch only nodes which have at least one childcollection

32 views
Skip to first unread message

Predrag Lazarević

unread,
Feb 16, 2014, 3:11:44 PM2/16/14
to phpcr...@googlegroups.com

I have following structure in phpcr

/foo1
/foo1/childcollection1
/foo1/childcollection2
/foo1/childcollection3
/foo2
/foo2/childcollection1
/foo2/childcollcetion2
/foo2/childcollection3
/foo2/childcollection4
/foo3
/foo4
/foo4/childcollection1
/foo4/childcollcetion2
...

I need to fatch only "foo" nodes which have at least one childcollection.

Childcollection is mapped in foo document as /** PHPCRODM\Children(fetchDepth=0) */

I was able to do it by following inner join query in my repository

$query = $this->createQueryBuilder('foo');
        $query->addJoinInner()
            ->right()->document('Path\PathBundle\Document\Childcollection', 'c')->end()
            ->condition()->child('c', 'foo');

As a result I do have foo documents which have at least one childcollection node, but when I add page functionality

$query->setMaxResults($limit);

I don't have a $limit number of documents. Result depends of number of childcollections in foo documents.

Can anybody help me with query to fetch only nodes with at least one childcollection and where I can add page functionality to that query.

Thanks and best regards

David Buchmann

unread,
Feb 19, 2014, 3:04:28 AM2/19/14
to phpcr...@googlegroups.com
hi predrag,

please either use the mailinglist (preferred) or stackoverflow, not both ;-)

so you are saying, the limit is applied to the child collections instead
of the filtered result? that sounds weird.

are you using jackalope-jackrabbit or jackalope-doctrine-dbal as storage
engine? can you please check with the other of the two if the bug is
specific to one phpcr implementation or global?

cheers,david

Predrag Lazarević

unread,
Feb 19, 2014, 5:16:14 AM2/19/14
to phpcr...@googlegroups.com
Hi, David

Ok, I will use mailing list only :)
I am using jackalope-jackrabbit, right now I cannot test it on doctrine-dbal, so I can't tell is it a global bug or not.
Thanks for your answer anyway.

Regards

David Buchmann

unread,
Feb 19, 2014, 12:13:04 PM2/19/14
to phpcr...@googlegroups.com
testing it on jackalope-doctrine-dbal should not be hard, you could use
the sqlite setup as you don't care about performance. that way we can
dtermine if its a problem on jackalope level or phpcr-odm. otherwise we
don't know where to look to fix it.

regards,david
> --
> You received this message because you are subscribed to the Google
> Groups "PHPCR User Group Mailinglist" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to phpcr-users...@googlegroups.com.
> To post to this group, send email to phpcr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/phpcr-users.
> For more options, visit https://groups.google.com/groups/opt_out.

--
Liip AG // Agile Web Development // T +41 26 422 25 11
CH-1700 Fribourg // PGP 0xA581808B // www.liip.ch
Reply all
Reply to author
Forward
0 new messages