title: Symfony2 - Find by a parent property object
body: <p>I understood how Query Builder works but I am trying to use the ORM correctly.</p>
  
  <p>I have two entities: Days and Tasks</p>
  
  <p>The Tasks entity is linked to the Day Entity with a ManyToOne association.</p>
  
  <p>Tasks.orm.yml</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>DJU\ MyBundle\ Entity\ Tasks:
    type: entity
  table: null
  repositoryClass: DJU\ MyBundle\ Entity\ TasksRepository
  id:
    id:
    type: integer
  id: true
  generator:
    strategy: AUTO
  fields:
    description:
    type: text
  manyToOne:
    days:
    targetEntity: Days
  inversedBy: tasks
  joinColumn:
    name: days_id
  referencedColumnName: id</code></pre>
  </div>
  </div>
  </p>
  
  <p>Tasks.php</p>
  
  <pre class="lang-php prettyprint-override"><code>class Tasks {
      /**
       * Get temps
       *
       * @return \CIT\CalendarBundle\Entity\Temps 
       */
      public function getTemps()
      {
          return $this-&gt;temps;
      }
  }
  </code></pre>
  
  <p>Here is my controller:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>class DefaultController extends Controller
  {
       public function example2CalAction() {
          $em = $this-&gt;getDoctrine()-&gt;getManager();
          $tasks = $em-&gt;getRepository('DJUMyBundle:Tasks')-&gt;findAll();
          
          foreach($tasks as $onetask) {
              if ( $onetask-&gt;getDays()-&gt;getId() == '1' ) {
                  $myt = $onetask-&gt;getDays();
              }
          }    
          return $this-&gt;render('DJUMyBundle:Default:sample2.html.twig', array('tasks' =&gt; $myt));
      }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>As you can see my request has poor performance. I would like to find Tasks by Days id. How can I do?</p>
  
  <p>Thank you</p>