title: doctrine 2: inheritance mapping join with parent table
body: <p>I have a base table like this:</p>
  <pre><code>class BaseProduct 
  {
      /**
       * @ORM\ManyToOne(targetEntity=&quot;ProductBundle\Entity\Category&quot;, inversedBy=&quot;baseProducts&quot;)
       * @ORM\JoinColumn(name=&quot;menu_category_id&quot;, referencedColumnName=&quot;id&quot;, nullable=true)
       **/
      protected $category;
  // ...
  </code></pre>
  <p>and another entity that inherit from BaseProduct</p>
  <pre><code>class ChildProduct extends BaseProduct
  {
  
      /**
       * @ORM\ManyToOne(targetEntity=&quot;ProductBundle\Entity\Category&quot;, inversedBy=&quot;childProducts&quot;)
       * @ORM\JoinColumn(name=&quot;menu_category_id&quot;, referencedColumnName=&quot;id&quot;, nullable=true)
       **/
      protected $category;
  </code></pre>
  <p>and Category entity:</p>
  <pre><code>class Category 
  {
      /**
       * @ORM\OneToMany(targetEntity=&quot;ProductBundle\Entity\BaseProduct&quot;, mappedBy=&quot;category&quot;)
       * @ORM\OrderBy({&quot;position&quot;= &quot;ASC&quot;})
       */
      private $baseProducts;
  
      /**
       * @ORM\OneToMany(targetEntity=&quot;ProductBundle\Entity\ChildProduct&quot;, mappedBy=&quot;category&quot;)
       * @ORM\OrderBy({&quot;position&quot;= &quot;ASC&quot;})
       */
      private $childProducts;
  </code></pre>
  <p>My <code>ChildProduct</code> table has one column named <code>id</code> and referenced to <code>BaseProduct</code> id's. Now I want to join Category with <code>ChildProduct</code> with this query:</p>
  <pre><code>    $qb-&gt;select('mc', 'cp')
          -&gt;from('ProductBundle:Category', 'mc')
          -&gt;leftJoin('mc.childProducts', 'cp')
          // .....
  </code></pre>
  <p>when I execute this query it gives this error:</p>
  <blockquote>
  <p>ContextErrorException in SqlWalker.php line 922:</p>
  <p>Notice: Undefined index: childProducts</p>
  </blockquote>
  <p>While I have <code>childProducts</code> in Category.</p>
  <p>Now I have two questions:</p>
  <ol>
  <li>am I able to query on a parent field that does not exists in child table.</li>
  <li>what's wrong with my query</li>
  </ol>