title: Symfony Doctrine : get field value in foreach loop on fetchAll()
body: <p>I'm trying to display some fields of a table 'Post' using a raw query :</p>
  
  <pre><code>$connection = $em-&gt;getConnection();
      $statement = $connection-&gt;prepare("SELECT * FROM Post WHERE category_id = 1");
      $statement-&gt;execute();
      $posts = $statement-&gt;fetchAll();
  
  ...
  
  foreach($posts as $post) {
          $xml .= $post-&gt;getId();
          $xml .= $post-&gt;getTitle();
          $xml .= $post-&gt;getContent();
      }
  </code></pre>
  
  <p>I've got an error <strong>"FatalErrorException: Error: Call to a member function getId() on a non-object in ..."</strong>
  All those getters are right in my Post entity. Any suggestion about what I'm doing wrong ?</p>
  
  <p><strong>[EDIT]</strong></p>
  
  <pre><code>$em = $this-&gt;getDoctrine()-&gt;getManager();
  
  $post_repository = $em-&gt;getRepository('MyBundle:Post'); 
  $posts = $post_repository-&gt;findBy(array('category_id' =&gt; 1));
  
  foreach($posts as $post) {
          $xml .= $post-&gt;getTitle();
      }
  </code></pre>
  
  <p>Returns me <strong>"Unrecognized field: category_id"</strong>.</p>
  
  <p>My Post class :</p>
  
  <pre><code>class Post
  {
  /**
  * @ORM\ManyToOne(targetEntity="MyBundle\Entity\Category", inversedBy="post")
  * @ORM\JoinColumns({
  *  @ORM\JoinColumn(name="category_id", referencedColumnName="id")
  * })
  */
  private $category;
  /**
  * Set category
  *
  @param MyBundle\Entity\Category $category
  */
  public function setCategory(\MyBundle\Entity\Category $category)
  {
      $this-&gt;category = $category;
  }
  /**
  * Get category
  *
  @return MyBundle\Entity\Category
  */
  public function getCategory()
  {
      return $this-&gt;category;
  }
  
  
  /**
   * @var integer
   *
   * @ORM\Column(name="id", type="integer")
   * @ORM\Id
   * @ORM\GeneratedValue(strategy="AUTO")
   */
  private $id;
  
  /**
   * @var string
   *
   * @ORM\Column(name="title", type="string", length=255)
   */
  private $title;
  
  ....
  </code></pre>