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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:15:54+00:00 2026-05-30T04:15:54+00:00

Symfony 2, Doctrine 2.1. I’ve got 3 entities, one of them intermediate (join table).

  • 0

Symfony 2, Doctrine 2.1.

I’ve got 3 entities, one of them intermediate (join table). Let’s say it’s SomeObject, SomeProperty and ObjectProperties.

Problem: I can’t get the value of SomeProperty ‘name’ property. Here’s the code:

[...]    
class SomeObject
{
 /**
 * @var integer $id
 *
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
 */
private $id;

  /**
   *
   * @var ObjectProperties $objectProperties
   *
   * @ORM\OneToMany(targetEntity="ObjectProperties", mappedBy="object_id", cascade={"all"})
   */
  private $objectProperties;
[...]

[...]
class SomeProperty
{
 /**
 * @var integer $id
 *
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="IDENTITY")
 * @ORM\OneToMany(targetEntity="ObjectProperties", mappedBy="property_id", cascade={"all"})
 */
private $id;


  /**
   * @var string $name
   *   
  */

private $name;//I NEED TO GET VALUE OF $name
[...]

[...]
class ObjectProperties
{
/**
 * @var integer $id
 *
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
 */
private $id;

/**
 * @ORM\ManyToOne(targetEntity="SomeObject", inversedBy="id", cascade={"all"})
 * @ORM\JoinColumn(name="object_id", referencedColumnName="id")
 */
private $object_id;

/**
 * @ORM\Id
 * @ORM\ManyToOne(targetEntity="SomeProperty", inversedBy="id", cascade={"all"})
 * @ORM\JoinColumn(name="property_id", referencedColumnName="id")
 */
private $property_id;
[...]

Setters and getters as usual.

In my controller I’ve got something along the lines of:

$entity = $em->getRepository('SomeTestBundle:SomeObject')->find($id);
[...]
$props = $entity->getObjectProperties();
    foreach ($props as $prop){
        echo '---------------------------<br>';
        var_dump($prop->getPropertyId()->getName());
    }

Now, getName() gives me null result, but if i replace it with getId it works as expected. Same if I try to use it in a form class. Is it because there is no doctrine association between SomeProperty->name and ObjectProperties?

I think I don’t quite get the way doctrine is supposed to work. I thought that only property_id and object_id are needed in a junction table, otherwise it doesn’t make much sense for me, because SomeProperty serves as a dictionary table, so I could change SomeProperty->name in one place.

I’m seriously stuck with it. Is it some sort of configuration option that is lacking or am I generally not getting the bigger picture?

  • 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-05-30T04:15:55+00:00Added an answer on May 30, 2026 at 4:15 am

    Consider it a typo – I’ve made it work by adding missing @Column annotation in SomeProperty class:

       /**
       * @var string $name
       * @ORM\Column(type="string")   
       */   
      private $name;
    

    Don’t know why I missed it in the first place… I guess “Experience is something you get, after you need it.”

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

Sidebar

Related Questions

I'm using Symfony 2 with Doctrine, and I've got two entities joined in a
I've got an SQL query that returns all the rows in one table (country)
How can i create a relationship between entities with Symfony 2 and Doctrine? I'm
I have an application that I'm converting to Symfony/Doctrine. It currently stores a serialized
im using symfony with doctrine, and Im trying to generate the schema yml file
I'm using symfony with doctrine and I make a registration form. Email field is
I just teach Symfony and Doctrine. I don't know hot to fetch 1 row
I'm using Symfony 2 with Doctrine. I have 4 classes: Country, District, County and
i'm having a little issue with doctrine using symfony 1.4 (I think it's using
I'm using Symfony 1.4 and Doctrine. So far I had no problem running tasks

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.