title: Symfony2: Join for find() results
body: <p>I'm new to Doctrine with Symfony and want to rewrite an old app of mine. For one view I need everything from one table, where I'd nomally use find(). But I also have to access anoter value via join. </p>
  
  <p>Is it possible, to combine the Query Builder with the find() method?</p>
  
  <p>This is my current Action:</p>
  
  <pre><code>$em = $this-&gt;getDoctrine()-&gt;getManager();        
  $rep = $em-&gt;getRepository('PaulInkBundle:Artist');
  $artist = $rep-&gt;find($id);
  $styles = $rep-&gt;getStyles($id);
  return $this-&gt;render('PaulInkBundle:Artist:artist.html.twig', array(
      'artist'    =&gt; $artist,
      'styles'    =&gt; $styles
  ));
  </code></pre>
  
  <p>The getStyles() method fetches the Styles linked to the artist:</p>
  
  <pre><code>public function getStyles($id)
      {
          return $this-&gt;getEntityManager()
              -&gt;createQuery(
                  'SELECT s.name 
                   FROM PaulInkBundle:Style s 
                   WHERE s.id IN (
                          SELECT st.style 
                          FROM PaulInkBundle:ArtistStyle st 
                         WHERE st.artist = :id ) '
             )-&gt;setParameter('id',$id)
              -&gt;getResult();
      }
  </code></pre>
  
  <p>Would it be possible to do this in one function and thus having the styles within the artist tat is passed to the view?</p>
  
  <p>Edit:</p>
  
  <p>The associations:</p>
  
  <p>Artist(nr) -> ArtistStyle(artist.nr/style.nr) &lt;- Style (nr,name)</p>
  
  <p>Thus, I want to get all Style-names with a specif artist ID</p>
  
  <pre><code>class Artist
  {
      /**
       * @var int
       *
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
      /**
       * @var string
       *
       * @ORM\Column(name="name", type="string", length=255)
       */
      private $name;
  }
  
  class ArtistStyle
  {
      /**
       * @var int
       *
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
      /**
       * @var int
       *
       * @ORM\Column(name="artist", type="integer")
       */
      private $artist;
  
      /**
       * @var int
       *
       * @ORM\Column(name="style", type="integer")
       */
      private $style;
  }
  
  class Style
  {
      /**
       * @var int
       *
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
      /**
       * @var string
       *
       * @ORM\Column(name="name", type="string", length=255, unique=true)
       */
      private $name;
  
      /**
       * @var string
       *
       * @ORM\Column(name="descr", type="text")
       */
      private $descr;
  }
  </code></pre>