title: Can't get custom repositories working
body: <p>I'm following the Symfony2 tutorial (chapter 4), but I am having trouble retrieving the <code>getLatestBlogs</code> method from my custom repository.</p>
  
  <p>I'm using Symfony 2.2 with Phar on Linux Mint.</p>
  
  <p>I created the repository myself, but I am stumped. I get this error:</p>
  
  <blockquote>
    <p>Undefined method 'getLatestBlogs'. The method name must start with either findBy or findOneBy! - BadMethodCallException</p>
  </blockquote>
  
  <p>I have googled other similar questions but to no avail. <strong>Can anybody spot the error in my code?</strong></p>
  
  <p><strong>Additional Info</strong></p>
  
  <p>My composer.json reads as follows :</p>
  
  <pre><code>"require": {
      "php": "&gt;=5.3.3",
      "symfony/symfony": "2.2.0", ** NOTE : Originally read 2.2.* but I changed and successfully ran a composer update **
      "doctrine/orm": "&gt;=2.2.3,&lt;2.4-dev",
      "doctrine/doctrine-bundle": "1.2.*",
      "twig/extensions": "1.0.*",
      "symfony/assetic-bundle": "2.1.*",
      "symfony/swiftmailer-bundle": "2.2.*",
      "symfony/monolog-bundle": "2.2.*",
      "sensio/distribution-bundle": "2.2.*",
      "sensio/framework-extra-bundle": "2.2.*",
      "sensio/generator-bundle": "2.2.*",
      "jms/security-extra-bundle": "1.4.*",
      "jms/di-extra-bundle": "1.3.*",
      "doctrine/doctrine-fixtures-bundle": "dev-master",
      "doctrine/data-fixtures" : "dev-master"        
  },
  </code></pre>
  
  <p>My <code>src/Blogger/BlogBundle/Controller/PageController.php</code>:</p>
  
  <pre class="lang-php prettyprint-override"><code>namespace Blogger\BlogBundle\Controller;
  
  use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  use Blogger\BlogBundle\Entity\Enquiry;
  use Blogger\BlogBundle\Form\EnquiryType;
  
  class PageController extends Controller
  {
      public function indexAction()
      {
          $em = $this-&gt;getDoctrine()
                 -&gt;getManager();
  
          $blogs = $em-&gt;getRepository('BloggerBlogBundle:Blog')-&gt;getLatestBlogs();
  
          return $this-&gt;render('BloggerBlogBundle:Page:index.html.twig', array(
              'blogs' =&gt; $blogs
          ));
      }
  </code></pre>
  
  <p>originally the lie 
  and my <code>src/Blogger/BlogBundle/Entity/Blog.php</code>:</p>
  
  <pre class="lang-php prettyprint-override"><code>namespace Blogger\BlogBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  
  /**
   * @ORM\Table(name="blog")
   * @ORM\Entity(repositoryClass="Blogger\BlogBundle\Repository\BlogRepository")
   * @ORM\HasLifecycleCallbacks()
   */
  class Blog
  {
  </code></pre>
  
  <p>and finally my <code>src/Blogger/BlogBundle/Repository/BlogRepository.php</code>:</p>
  
  <pre class="lang-php prettyprint-override"><code>namespace Blogger\BlogBundle\Repository;
  
  use Doctrine\ORM\EntityRepository;
  
  /**
   * BlogRepository
   *
   * This class was generated by the Doctrine ORM. Add your own custom
   * repository methods below.
   */
  class BlogRepository extends EntityRepository
  {
  
      public function getLatestBlogs($limit = null)
      {
          $qb = $this-&gt;createQueryBuilder('b')
                     -&gt;select('b')
                     -&gt;addOrderBy('b.created', 'DESC');
  
          if (false === is_null($limit))
              $qb-&gt;setMaxResults($limit);
  
          return $qb-&gt;getQuery()
                    -&gt;getResult();
      }
  
  }
  </code></pre>