title: Need help getting OneToMany association from ManyToOne
body: <p>Let me start off by saying I asked a similar question before and got it answered. I tried using those principles here but I'm stuck again am am not sure where to go from here. </p>
  
  <p>I have a page where I list out all the 'products' along with their respected id's, price, and name. On this same page I want to get a description I created for each of them. Description is its own entity and has it's own controller. </p>
  
  <p>In my <code>ProductController</code>, within my <code>indexAction</code>, I'm trying to get the description to appear here. </p>
  
  <p>The problem is, I don't reference an id within <code>indexAction</code> (I use findAll). I have tried to loop through all products and reference using <code>$key</code> but I either get the most recent description entered in description or currently:</p>
  
  <p><em>Error: Call to a member function getDescriptions() on a non-object.</em></p>
  
  <p>EDIT: I should mention $prodEnt is null...</p>
  
  <p>I didn't want to come here for help but I have no more thoughts on how to go about getting what I want. </p>
  
  <p>Here is <code>ProductController</code> with <code>indexAction</code>:</p>
  
  <pre><code>namespace Pas\ShopTestBundle\Controller;
  
  use Symfony\Component\HttpFoundation\Request;
  use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
  use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  use Pas\ShopTestBundle\Entity\Product;
  use Pas\ShopTestBundle\Form\ProductType;
  
  /**
   * Product controller.
   *
   * @Route("/product")
   */
  class ProductController extends Controller
  {
      /**
       * Lists all Product entities.
       *
       * @Route("/", name="product")
       * @Method("GET")
       * @Template()
       */
      public function indexAction()
      {
          $em = $this-&gt;getDoctrine()-&gt;getManager();
  
          $entities = $em-&gt;getRepository('PasShopTestBundle:Product')-&gt;findAll();
  
          //$entities = $em-&gt;getRepository('PasShopTestBundle:Product')-&gt;find($id);
          //var_dump($entities);
          //dump($entities); die;
  
          if (!$entities) {
              throw $this-&gt;createNotFoundException('Error Nothing in Entities.');
          } 
          else {
              //dump($entities); die;
              foreach ($entities as $key =&gt; $entity) {
                  //dump($entities); die;
                  //dump($entity); die;
                  //dump($key); die; //needs to be 1
                  //$entity = $em-&gt;getRepository('PasShopTestBundle:Product')-&gt;findAll($key);
                  $prodEnt = $em-&gt;getRepository('PasShopTestBundle:Product')-&gt;find($key);
                  //dump($entity); die;
                  //dump($prodEnt); die;
                  $descriptions = $prodEnt-&gt;getDescriptions();
                  //dump($entity); die;
              }
              //dump($entities); die;
          }
  
          return array(
              'descriptions' =&gt; $descriptions,
              'entities' =&gt; $entities,
              'entity' =&gt; $entity,
          );
      }
  </code></pre>
  
  <p>Here is <code>indexAction</code>s Route twig file:</p>
  
  <pre><code>{% extends '::base.html.twig' %}
  
  {% block body -%}
      &lt;h1&gt;Product List&lt;/h1&gt;
  
      &lt;table class="records_list"&gt;
          &lt;thead&gt;
              &lt;tr&gt;
                  &lt;th&gt;Id&lt;/th&gt;
                  &lt;th&gt;Name&lt;/th&gt;
                  &lt;th&gt;Price&lt;/th&gt;
                  &lt;th&gt;Quantity&lt;/th&gt;
                  &lt;th&gt;Description&lt;/th&gt;
                  &lt;th&gt;Actions&lt;/th&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
          {% for entity in entities %}
              &lt;tr&gt;
                  &lt;td&gt;&lt;a href="{{ path('product_show', { 'id': entity.id }) }}"&gt;{{ entity.id }}&lt;/a&gt;&lt;/td&gt;
                  &lt;td&gt;{{ entity.name }}&lt;/td&gt;
                  &lt;td&gt;{{ entity.price }}&lt;/td&gt;
                  &lt;td&gt;{{ entity.quantity }}&lt;/td&gt;
  
                  {% for key, entity in descriptions %}
  
                      &lt;pre&gt;{{ dump(entity) }}&lt;/pre&gt;
  
                     {# &lt;pre&gt;{{ dump(key) }}&lt;/pre&gt; #}
  
                          &lt;td&gt;{{ entity.productDesciption }}&lt;/td&gt;
  
                      &lt;pre&gt;{{ dump(entity.productDesciption) }}&lt;/pre&gt;
  
                  {% endfor %}
  
                  &lt;td&gt;
                      &lt;ul&gt;
                          &lt;li&gt;
                              &lt;a href="{{ path('product_cart', { 'id': entity.id }) }}"&gt;Add Product To Cart&lt;/a&gt;
                          &lt;/li&gt;
                          &lt;li&gt;
                              &lt;a href="{{ path('product_show', { 'id': entity.id }) }}"&gt;show&lt;/a&gt;
                          &lt;/li&gt;
                          &lt;li&gt;
                              &lt;a href="{{ path('product_edit', { 'id': entity.id }) }}"&gt;edit&lt;/a&gt;
                          &lt;/li&gt;
                      &lt;/ul&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          {% endfor %}
          &lt;/tbody&gt;
      &lt;/table&gt;
  
          &lt;ul&gt;
          &lt;li&gt;
              &lt;a href="{{ path('product_new') }}"&gt;
                  Create a new entry
              &lt;/a&gt;
          &lt;/li&gt;
      &lt;/ul&gt;
      {% endblock %}
  </code></pre>
  
  <p>Product Entity:</p>
  
  <pre><code>namespace Pas\ShopTestBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use Doctrine\Common\Collections\ArrayCollection;
  
  /**
   * Product
   *
   * @ORM\Table(name="products")
   * @ORM\Entity(repositoryClass="Pas\ShopTestBundle\Entity\ProductRepository")
   */
  class Product
  {
      /**
       * @var ArrayCollection
       *
       * @ORM\OneToMany(targetEntity="Description", mappedBy="product")
       */
      private $descriptions;
  </code></pre>
  
  <p>Description Entity:</p>
  
  <pre><code>namespace Pas\ShopTestBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use Doctrine\Common\Collection\ArrayCollection;
  
  /**
   * Description
   *
   * @ORM\Table(name="descriptions")
   * @ORM\Entity(repositoryClass="Pas\ShopTestBundle\Entity\DescriptionRepository")
   */
  class Description
  {
      /**
       * @var string
       *
       * @ORM\Column(name="name", type="string")
       */
      private $productDescription;
  
      /**
       * @var Product
       *
       * @ORM\ManyToOne(targetEntity="Product", inversedBy="descriptions")
       * @ORM\JoinColumn(name="product_id", referencedColumnName="id")
       */
      private $product;
  </code></pre>
  
  <p>Any help is really appreciated, Thanks!</p>