title: symfony2 doctrine findBy id in arrayCollection
body: <p>Using Symfony2.3.4 and Doctrine.  </p>
  
  <p>I have a class Student with a ManyToMany relation with a class Edition.</p>
  
  <p>Now in my StudentController I have this IndexAction($edition_id) to list not all students in the DB but only those related to the given Edition id.</p>
  
  <pre><code>$entities = $em-&gt;getRepository('PersonBundle:Student')-&gt;findBy(array(
      ????????
  ));
  </code></pre>
  
  <p>I'm thinking of some kind of criteria to use with $edition_id but can't come up with any.</p>
  
  <p>Tips appreciated, thanks.</p>
  
  <p>@dmnptr:
  I'm trying that, I'm quite new to this so tell me if I did something wrong.</p>
  
  <p>I put that function you wrote in the controller and in the method IndexAction($edition) I added </p>
  
  <pre><code>$students = this-&gt;findAllByEdition($edition);
  </code></pre>
  
  <p>now the problem is that the parameter $edition is coming from a twig template like this:</p>
  
  <pre><code>&lt;a href="{{ path('student', { 'edition': entity}) }}"&lt;/a&gt;
  </code></pre>
  
  <p>being <strong>entity</strong> who holds the Edition object. </p>
  
  <p>But when I do it like this <strong>entity</strong> returns the __toString() method, meaning a string with the name of the edition, not the edition itself which is what the function you gave me uses. </p>
  
  <p>Now, do you happen to know a way to get the object itself from the template, not the __toString() method, thanks...</p>