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 8722805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:29:35+00:00 2026-06-13T07:29:35+00:00

My problem is related to the lazy-loading functionality of Doctrine 2. Let’s say I

  • 0

My problem is related to the lazy-loading functionality of Doctrine 2.

Let’s say I have these 2 Entities:

  • Area
  • Venue

Here are quick specs:

  • An Area can contain other areas (sub-areas…)
  • A Venue is located in only 1 area
  • Area::getFullName() should output “Parent area name (if any) > Area name”

My PHP Entities are:

class Area extends AbstractEntity {
/**
 * @ORM\ManyToOne(targetEntity="Area", inversedBy="children")
 */
private $parent;

public function getFullName() {
    if (!isset($this->fullName)) {
        $this->fullName = ($this->getParent() ? $this->getParent()->name . ' > ' : '') . $this->name;
    }
    return $this->fullName;
}

class Venue extends AbstractEntity {

/** 
 * @ORM\ManyToOne(targetEntity="Area")
 */
private $area;

Let’s say that area “Paris” contains a subarea named “Center”

If I call:

$area = $repoArea->findByUrl("paris/center")
echo $area->getFullName();
// --> "Paris > Center"

So far, so good.

But let’s say now, that the “Fouquet’s” restaurant is one Venue in the center of Paris:

$venue = $repoVenue->findByName("Fouquet's");
echo $venue->getArea()->getFullName()
// --> " > Center"

The parent area name (–> “Paris”) is not output…

$this->fullName = ($this->getParent() ? $this->getParent()->name . ' > ' : '') . $this->name;

But the parent Area Proxy Object is not NULL. It is just not initialized. And so calling the property “name” returns NULL.

It seems that “double” (or “many-to-one of many-to-one”…) lazy loading fails. Something like:

$venue->getArea()->get(Parent)Area()->name
  • 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-13T07:29:36+00:00Added an answer on June 13, 2026 at 7:29 am

    Properties should never be public when using Doctrine. This will lead
    to bugs with the way lazy loading works in Doctrine.

    Source: Doctrine’s Getting Started


    Basically, you should add a getName() method to your Area class and use ->getName() instead of ->name so Doctrine can intercept the call and load the Proxy object’s data. 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem related to an array data which fetched from an external
hello I am having problem related to https:// . I have used FB.getLoginStatus(function(response) function
I have a performance problem related to string comparison (in Java). I'm working on
I'm using EJB3 and I have a problem related to refreshing my EntityManager .
I have the problem related to showing the button on the page. There are
All, I have a problem related to imageView, android. I have array which contains
I am working on CUDA and I have a problem related to thread synchronization.
I'm new to c language and Linux. I have a problem related to fork(),getpid()and
I have a problem related to parsing a SOAP message. This is the message:
I have a problem related to creating an instance of a WCF ServiceHost withing

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.