Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8622947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:10:17+00:00 2026-06-12T07:10:17+00:00

I have a entity like this: Person – id_person – name – child //self

  • 0

I have a entity like this:

Person
  - id_person
  - name
  - child //self refering

If I query person entity in a recursive funcion it only returns me the first three levels. Do you know how to tell to doctrine that I want to get deep as many levels is required?

Edit

What was the problem?
Using $queryBuilder->getquery()->getResult(Query::HIDRATE_ARRAY); is not the best way to make a recursive function, it should use the default hydration.

How I resolve it?
Using $queryBuilder->getquery()->getResult(); and call the getters as @Andreas Linden say: $parent->getChild()

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:10:18+00:00Added an answer on June 12, 2026 at 7:10 am

    all associations will be lazy loaded when you access them from within your model 8if you don’t define it to behave differently). so always use getter methods like getChild() which simply does return $this->child;

    you can also left-join as many levels as you require so you won’t generate thousands of queries (a single query for each child)

    $query = $entityManager->createQueryBuilder()
        ->select('p1, p2, p3, p4, p5, p6')
        ->from('Entity\Person', 'p1')
        ->leftJoin('p1.child', 'p2')
        ->leftJoin('p2.child', 'p3')
        ->leftJoin('p3.child', 'p4')
        ->leftJoin('p4.child', 'p5')
        ->leftJoin('p5.child', 'p6')
        ->createQuery();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an entity like this: public class Person { public string Name {
I have a Person and an Organisation Entity: Person looks like this: public class
If I have entities like: @Entity public class Person { public String name; @OneToMany
I have entity model like this (using EclipseLink and JPA 2.0): @Entity class A
I have an entity which looks like this: Entityname = Country with the attributes
I have an entity which looks something like this: (I'm coding to the web
I have an Entity in Code First Entity framework that currently looks like this:
I have a Customer class defined like this: @Entity public class Customer { //...
I have a JPA object which has a many-to-many relationship like this: @Entity public
I have two tables associated by FK. Table student is mapped like this: @Entity

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.