title: Doctrine select multiple objects
body: <p>I have 2 classes that I want to select from DB using 1 query in Symfony2 Doctrine.</p>
  
  <p>The first entity is <code>Calculation</code> and the second is <code>Polynomial</code>. They have 1:1 relationship:</p>
  
  <pre><code>/**
   * Acme\UserBundle\Entity\Calculation
   *
   * @ORM\Table(name="Calculation")
   * @ORM\Entity(repositoryClass="AppBundle\Entity\CalculationRepository")
   */
  class Calculation {
      //...
      /**
       * @ORM\OneToOne(targetEntity="Polynomial")
       * @ORM\JoinColumn(name="result_polynomial_id", referencedColumnName="id", nullable=false)
       **/
      private $resultPolynomial;
      //...
  }
  </code></pre>
  
  <p>I have a query, that returns me all Calculations of one user:</p>
  
  <pre><code>public function findByUser( $user ) {
      return $this-&gt;getEntityManager()-&gt;createQuery(
                  'SELECT c
                   FROM AppBundle:User u
                      JOIN AppBundle:Polynomial p WITH u = p.user
                      JOIN AppBundle:Calculation c WITH p = c.resultPolynomial
                   WHERE u = :user
                   ORDER BY c.id'
              )
              -&gt;setParameter('user', $user)
              -&gt;getResult();
  }
  </code></pre>
  
  <p>And to the question... Is there a way to get resultPolynomials of the calculations in one query? If I use something like <code>SELECT c, c.resultPolynomial</code> I get error:</p>
  
  <pre><code>[Semantical Error] line 0, col 12 near 'resultPolynomial
  ': Error: Invalid PathExpression. Must be a StateFieldPathExpression.
  </code></pre>
  
  <p>And if I use <code>foreach</code> cycle all calculations to get the their resultPolynomials there are many queries to the DB (1 for each calculation) and it is not good for performance if I have many calculations.</p>