title: Symfony2 query error (while the same works under Doctrine2)
body: <p>I am using both Doctrine2 and Symfony2 but Symfony2 fails me at a task I am able to accomplish in Doctrine2 (the 'standalone' version).</p>
  
  <p>In Doctrine2:</p>
  
  <p>I have 2 classes, Outcome, Ticket as such:</p>
  
  <pre><code>namespace Entity;
  /** @Entity @Table(name="tickets") */
  class Ticket {
      /**  @Id @Column(type="integer") @GeneratedValue(strategy="AUTO") */
      private $id;
      /** @Column(type="string", length=100) */
      private $title;
      /** @OneToMany(targetEntity="Outcome", mappedBy="ticket") */
      private $outcomes;
      /* with setters and getters for title and outcomes */
      public function __toString() {
          return  $this-&gt;getTitle().' ('.$this-&gt;getId().')';
      }
      public function __construct () {
          $this-&gt;outcomes=new \Doctrine\Common\Collections\ArrayCollection();
      }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>namespace Entity;
  /** @Entity @Table(name="outcomes") */
  class Outcome  {
      /** @Id @Column(type="integer") @GeneratedValue(strategy="AUTO") */
      private $id;
      /** @Column(type="string", length=100) */
      private $text;
      /** @ManyToOne(targetEntity="Ticket", inversedBy="outcomes") @JoinColumn(nullable=false) */
      private $ticket;
      public function __toString() {
          return  $this-&gt;getText().' ' .' ('.$this-&gt;getId().')';
      }
  }
  </code></pre>
  
  <p>in my index.php I use</p>
  
  <pre><code>$query = $em-&gt;createQuery ("SELECT t,o FROM Entity\Ticket t LEFT JOIN t.outcomes o WHERE t.id=1");
  $query-&gt;useResultCache(true);
  $tickets_2 = $query-&gt;execute();
  $ticket_2 = $tickets_2[0];
  $amount=count($ticket_2-&gt;getOutcomes());
  echo $ticket_2." --ticket\n";
  echo $amount." --outcomes\n";
  </code></pre>
  
  <p>and I get the correct output</p>
  
  <p>now in Symfony2 I use the following definitions for the entities:</p>
  
  <pre><code>namespace test\DemoBundle\Entity;
  /** @orm:Entity @orm:Table(name="tickets") */
  class Ticket {
      /**  @orm:Id @orm:Column(type="integer") 
           @orm:GeneratedValue(strategy="AUTO") */
      private $id;
      /** @orm:Column(type="string", length=100) */
      private $title;
      /** @orm:OneToMany(targetEntity="Outcome", mappedBy="response") */
      private $outcomes;
      ...
  }
  </code></pre>
  
  <pre class="lang-php prettyprint-override"><code>namespace test\DemoBundle\Entity;
  /** @orm:Entity @orm:Table(name="outcomes") */
  class Outcome  {
      /** @orm:Id @orm:Column(type="integer") @orm:GeneratedValue(strategy="AUTO") */
      private $id;
      /** @orm:Column(type="string", length=100) */
      private $text;
      /** @orm:ManyToOne(targetEntity="Ticket", inversedBy="outcomes") @orm:JoinColumn(nullable=false) */
      private $ticket;
      ....
  }
  </code></pre>
  
  <p>now, I've set up a controller with a test function:</p>
  
  <pre><code>namespace test\DemoBundle\Controller;
  use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  use Symfony\Component\HttpFoundation\Response;
  use test\DemoBundle\Entity\Ticket as Ticket;
  use test\DemoBundle\Entity\Outcome as Outcome;
  class TicketController extends Controller { 
      ...
      public function testAction() {
          $em = $this-&gt;get('doctrine.orm.entity_manager');  
          $query = $em-&gt;createQuery ("SELECT t, o
              FROM test\DemoBundle\Entity\Ticket t  
              LEFT JOIN  t.outcomes o
              WHERE t.id=1");
          $query-&gt;useResultCache(true);
          $tickets_2 = $query-&gt;execute();
          $ticket_2 = $tickets_2[0];
          $amount=count($ticket_2-&gt;getOutcomes());
          $prepared_result=$ticket_2." --ticket ".$amount." --outcomes ";
          $response = new Response($prepared_result);
          return $response; 
      }
  }
  </code></pre>
  
  <p>at this point I get an error while trying to execute the last query like so:</p>
  
  <blockquote>
    <p>SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE t0_.id = 1' at line 1 </p>
  </blockquote>
  
  <p>from the webdebugger I get the following syntax from PDO:</p>
  
  <pre class="lang-sql prettyprint-override"><code>SELECT t0_.id AS id0,
   t0_.title AS title1,
   o1_.id AS id2,
   o1_.text AS text3,
   o1_.ticket_id AS ticket_id4
  FROM tickets t0_ 
  LEFT JOIN WHERE t0_.id = 1
  </code></pre>
  
  <p>so I guess I am missing something after the LEFT JOIN so that's why I am gettint the error in the first place?</p>
  
  <p>What am I doing wrong?/What should I do?</p>