title: How do i solve Semantical error: "Class has no association named.."
body: <p>i am following part 5 of the symblog symfony2 tutorial:</p>
  
  <pre><code>http://tutorial.symblog.co.uk/docs/customising-the-view-more-with-twig.html
  </code></pre>
  
  <p>under heading: The Homepage - Blogs and Comments</p>
  
  <p>when i get to update:</p>
  
  <pre><code>// src/Blogger/BlogBundle/Repository/BlogRepositoy.php
  
  public function getLatestBlogs($limit = null)
  {
      $qb = $this-&gt;createQueryBuilder('b')
             -&gt;select('b, c')
             -&gt;leftJoin('b.comments', 'c')
             -&gt;addOrderBy('b.created', 'DESC');
  
      if (false === is_null($limit))
      $qb-&gt;setMaxResults($limit);
  
      return $qb-&gt;getQuery()
            -&gt;getResult();
  }
  </code></pre>
  
  <p>and also when i update:</p>
  
  <pre><code>{# src/Blogger/BlogBundle/Resources/views/Page/index.html.twig #}
  
  {# .. #}
  
  &lt;footer class="meta"&gt;
      &lt;p&gt;Comments: &lt;a href="{{ path('BloggerBlogBundle_blog_show', { 'id': blog.id }) }}#comments"&gt;{{ blog.comments|length }}&lt;/a&gt;&lt;/p&gt;
      &lt;p&gt;Posted by &lt;span class="highlight"&gt;{{ blog.author }}&lt;/span&gt; at {{ blog.created|date('h:iA') }}&lt;/p&gt;
      &lt;p&gt;Tags: &lt;span class="highlight"&gt;{{ blog.tags }}&lt;/span&gt;&lt;/p&gt;
  &lt;/footer&gt;
  
  {# .. #}
  </code></pre>
  
  <p>i then refresh my browser and get error:</p>
  
  <pre><code>[Semantical Error] line 0, col 71 near 'c ORDER BY b.created': Error: Class   
  Blogger\BlogBundle\Entity\Blog has no association named comments
  500 Internal Server Error - QueryException
  
  
  &lt;?php
   // src/Blogger/BlogBundle/Entity/Blog.php
  
   namespace Blogger\BlogBundle\Entity;
  
   use Doctrine\ORM\Mapping as ORM;
   use Doctrine\Common\Collections\ArrayCollection;
  
  /**
   * @ORM\Entity(repositoryClass="Blogger\BlogBundle\Repository\BlogRepository")
   * @ORM\Table(name="blog")
   * @ORM\HasLifecycleCallbacks()
   */
  class Blog
  {
  public function __toString()
  {
      return $this-&gt;getTitle();
  }
  
  /**
   * @ORM\Id
   * @ORM\Column(type="integer")
   * @ORM\GeneratedValue(strategy="AUTO")
   */
  protected $id;
  
  /**
   * @ORM\Column(type="string")
   */
  protected $title;
  
  /**
   * @ORM\Column(type="string", length=100)
   */
  protected $author;
  
  /**
   * @ORM\Column(type="text")
   */
  protected $blog;
  
   /**
   * @ORM\Column(type="string", length="20")
   */
  protected $image;
  
  /**
   * @ORM\Column(type="text")
   */
  protected $tags;
  
  protected $comments;
  
  /**
   * @ORM\Column(type="datetime")
   */
  protected $created;
  
  /**
   * @ORM\Column(type="datetime")
   */
  protected $updated;
  
  
  public function __construct()
  {
      $this-&gt;comments = new ArrayCollection();
  
      $this-&gt;setCreated(new \DateTime());
      $this-&gt;setUpdated(new \DateTime());
  }
  
  public function setUpdatedValue()
  {
     $this-&gt;setUpdated(new \DateTime());
  }
  
  /**
   * Get id
   *
   * @return integer 
   */
  public function getId()
  {
      return $this-&gt;id;
  }
  
  /**
   * Set title
   *
   * @param string $title
   */
  public function setTitle($title)
  {
      $this-&gt;title = $title;
  }
  
  /**
   * Get title
   *
   * @return string 
   */
  public function getTitle()
  {
      return $this-&gt;title;
  }
  
  /**
   * Set author
   *
   * @param string $author
   */
  public function setAuthor($author)
  {
      $this-&gt;author = $author;
  }
  
   /**
   * Get author
   *
   * @return string 
   */
  public function getAuthor()
  {
      return $this-&gt;author;
  }
  
  /**
   * Set blog
   *
   * @param text $blog
   */
  public function setBlog($blog)
  {
      $this-&gt;blog = $blog;
  }
  
  /**
   * Get blog
   *
   * @return text 
   */
  public function getBlog($length = null)
  {
      if (false === is_null($length) &amp;&amp; $length &gt; 0)
         return substr($this-&gt;blog, 0, $length);
      else
         return $this-&gt;blog;
  }
  
  /**
   * Set image
   *
   * @param string $image
   */
  public function setImage($image)
  {
      $this-&gt;image = $image;
  }
  
  /**
   * Get image
   *
   * @return string 
   */
  public function getImage()
  {
      return $this-&gt;image;
  }
  
  /**
   * Set tags
   *
   * @param text $tags
   */
  public function setTags($tags)
  {
      $this-&gt;tags = $tags;
  }
  
  /**
   * Get tags
   *
   * @return text 
   */
  public function getTags()
  {
      return $this-&gt;tags;
  }
  
  /**
   * Set created
   *
   * @param datetime $created
   */
  public function setCreated($created)
  {
      $this-&gt;created = $created;
  }
  
  /**
   * Get created
   *
   * @return datetime 
   */
  public function getCreated()
  {
      return $this-&gt;created;
  }
  
  /**
   * Set updated
   *
   * @param datetime $updated
   */
  public function setUpdated($updated)
  {
      $this-&gt;updated = $updated;
  }
  
  /**
   * Get updated
   *
   * @return datetime 
   */
  public function getUpdated()
  {
      return $this-&gt;updated;
  }
  }
  </code></pre>
  
  <p>please help solve this. i dont know where i went wrong</p>
  
  <p>thanks</p>