title: DQL query returns: StateFieldPathExpression or SingleValuedAssociationField expected
body: <p>I have the following DQL query:</p>
  
  <pre><code>public function findByIdJoinedToCodeExample($pageId)
  {
      $query = $this-&gt;getEntityManager()
          -&gt;createQuery('
              SELECT c FROM acmeStyleGuideBundle:codeExample c
              JOIN c.PageContent p
              WHERE p.codeExample = :cex'
          )
          -&gt;setParameter('cex', $pageId);
  
      try {
          return $query-&gt;getResult();
      } catch (\Doctrine\ORM\NoResultException $e) {
          return null;
      }
  }
  </code></pre>
  
  <p>It is attempting to retreive data from an entity called codeExample which has a ManyToOne relationship with an entity called PageContent. The relationships seem to be set up correctly as the database is being correctly set up and the fixtures are being populated but when I try to run the above query I am faced with the following error:</p>
  
  <blockquote>
    <p>An exception has been thrown during the rendering of a template ("[Semantical Error] line 0, col 130 near 'codeExample =': Error: Invalid PathExpression. StateFieldPathExpression or SingleValuedAssociationField expected.") in acmeStyleGuideBundle:Page:pages.html.twig at line 16.</p>
  </blockquote>
  
  <p><strong>It is being called by the following controller:</strong></p>
  
  <pre><code>// find the current pages code examples (if there are any)
  public function findCodeExamplesAction($pageId =10) 
  {
      $em = $this-&gt;getDoctrine()-&gt;getManager();
      $codeExample = $this-&gt;getDoctrine()
      -&gt;getRepository('acmeStyleGuideBundle:codeExample')
      -&gt;findByIdJoinedToCodeExample($pageId);
      return $this-&gt;render(
          'acmeStyleGuideBundle:Page:codeExample.html.twig', 
          array(
              'Code' =&gt; $codeExample
          )
      );
  }
  </code></pre>
  
  <p><em>Note: $pageID = 10 is because it was telling me that pageID wasn't being populated. That seems to be a separate issue than this one so I set a default for that for now.</em></p>
  
  <p>I've been looking at this for hours but I'm still learning Doctrine and Symfony and I just cannot figure this one out by myself. </p>
  
  <p><strong>Here are my entities for codeExample:</strong></p>
  
  <pre><code>/**
   * @var integer
   *
   * @ORM\Column(name="id", type="integer")
   * @ORM\Id
   * @ORM\GeneratedValue(strategy="AUTO")
   */
      private $id;
  
  /**
   * @var string
   *
   * @ORM\Column(name="textExample", type="text")
   */
      private $textExample;
  
  /**
   * @var string
   *
   * @ORM\Column(name="codeExample", type="text")
   */
      private $codeExample;
  
  /**
   * @var integer
   *
   * @ORM\Column(name="lang", type="integer")
   */
      private $lang;
  
  /**
   * @ORM\ManyToMany(targetEntity="PageContent", mappedBy="codeExample")
   */
      protected $PageContent;
  
  /**
   * Constructor
   */
  public function __construct()
  {
      $this-&gt;PageContent = new \Doctrine\Common\Collections\ArrayCollection();
  }
  </code></pre>
  
  <p><strong>Here are my entities for PageContent:</strong></p>
  
  <pre><code>/**
   * @var integer
   *
   * @ORM\Column(name="id", type="integer")
   * @ORM\Id
   * @ORM\GeneratedValue(strategy="AUTO")
   */
      private $id;
  
  /**
   * @var ArrayCollection $pageSector_Id;
   * @ORM\ManyToMany(targetEntity="pageSector", inversedBy="PageContent")
   * @ORM\JoinTable(
   *      name="pageSector_PageContent",
   *      joinColumns={@ORM\JoinColumn(name="PageContent_id", referencedColumnName="id")},
   *      inverseJoinColumns={@ORM\JoinColumn(name="pageSector_Id", referencedColumnName="id")}
   *      )
   */
      protected $pageSector;
  
   /**
   * @var ArrayCollection $pageCategory_Id;
   * @ORM\ManyToMany(targetEntity="pageCategory", inversedBy="PageContent")
   * @ORM\JoinTable(
   *      name="pageCategory_PageContent",
   *      joinColumns={@ORM\JoinColumn(name="PageContent_id", referencedColumnName="id")},
   *      inverseJoinColumns={@ORM\JoinColumn(name="pageCategory_Id", referencedColumnName="id")}
   *      )
   */
      protected $pageCategory;
  
  /**
   * @ORM\ManyToOne(targetEntity="pageTypes", inversedBy="PageContent")
   * @ORM\JoinColumn(name="pageTypesId", referencedColumnName="id")
   */
      protected $pageTypes;
  
  /**
   * @var integer
   *
   * @ORM\Column(name="pageTypesId", type="integer")
   */
  
      private $pageTypesId;
  
  /**
   * @ORM\OneToMany(targetEntity="PageContent", mappedBy="parentPage")
   */
      private $childPages;
  
   /** @ORM\ManyToOne(targetEntity="PageContent", inversedBy="childPages")
   *   @ORM\JoinColumn(name="parentPage_id", referencedColumnName="id")
   **/
      private $parentPage;
  
  /**
   * @var string
   *
   * @ORM\Column(name="pageName", type="string", length=255)
   */
      private $pageName;
  
  /**
   * @var string
   *
   * @ORM\Column(name="pageUrl", type="string", length=255)
   */
      private $pageUrl;
  
  /**
   * @var string
   *
   * @ORM\Column(name="richText", type="text")
   */
      private $richText;
  
  /**
   * @var ArrayCollection $pageSector_Id;
   * @ORM\ManyToMany(targetEntity="codeExample", inversedBy="PageContent")
   * @ORM\JoinTable(
   *      name="codeExample_PageContent",
   *      joinColumns={@ORM\JoinColumn(name="PageContent_id", referencedColumnName="id")},
   *      inverseJoinColumns={@ORM\JoinColumn(name="codeExample_Id", referencedColumnName="id")}
   *      )
   */
      protected $codeExample;
  </code></pre>
  
  <p>Any advice you can give me would be amazing. I'm completely stuck here.</p>