title: Doctrine2 query with select on multiple entities from different Symfony2 bundles
body: <p>Hello I have three Doctrine2 entities in my Symfony2 application: two ("Promo" and "PromoPeriod") in the bundle Acme:PromoBundle; one ("Shop") in the bundle Acme:ShopBundle.
  The relationships are:
  Promo - PromoPeriod: <em>Many-to-One</em>.
  PromoPeriod - Shop: <em>One-to-Many</em>.</p>
  
  <p>In the repository of the entity "Promo", I try to get all the promo and shops as follows:</p>
  
  <pre><code>    return $this-&gt;getEntityManager()
          -&gt;createQuery("SELECT p, s
              FROM AcmePromoBundle:Promo p JOIN p.period pp JOIN pp.shops s")
              -&gt;getResult();
  </code></pre>
  
  <p>where: p.period is the relationship between the Promo instance p and the PromoPeriod period; pp.shops is the relationship between the PromoPeriod pp and the Shops.
  The following error is returned:</p>
  
  <pre><code>An exception has been thrown during the rendering of a template 
  ("The parent object of entity result with alias 's' was not found. 
  The parent alias is 'pp'.")
  </code></pre>
  
  <p>So, I argued that Doctrine is not capable of understanding the type of "s" (which is a Shop entity), since it is located in another bundle. Hence I tried to add an INSTANCE OF clause: </p>
  
  <pre><code>SELECT p, s
  FROM AcmePromoBundle:Promo p JOIN p.period pp JOIN pp.shops s
  WHERE s INSTANCE OF AcmeShopBundle:Shop
  </code></pre>
  
  <p>And again nothing. Perhaps this is not the way to solve the problem.</p>
  
  <p>Any idea?</p>