title: Symfony2 : Repository Class not found
body: <p>Today I stuck in Repository Class Function I got this error </p>
  
  <p><strong>Undefined method 'test'. The method name must start with either findBy or findOneBy!</strong> </p>
  
  <p>I allready checked these solutions -
  <a href="https://stackoverflow.com/questions/9172586/the-method-name-must-start-with-either-findby-or-findoneby-undefined-method-sym">Solution 1</a>
  <a href="https://stackoverflow.com/questions/15314683/cant-get-custom-repositories-working">Solution 2</a>
  <a href="https://stackoverflow.com/questions/10481916/the-method-name-must-start-with-either-findby-or-findoneby-uncaught-exception">Solution 3</a></p>
  
  <p><strong>Is anything I need to add into config file ?</strong></p>
  
  <p>This is my Entity Class</p>
  
  <pre><code>// src/Foo/NewsBundle/Entity/News.php
  namespace Foo\NewsBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  
  /**
   * News
   * @ORM\Entity(repositoryClass="Foo\NewsBundle\Repository\NewsRepository")
   * @ORM\Table(name="news")
   * @ORM\HasLifecycleCallbacks()
   */
  class News
  {
      /**
       * @var integer
       */
      private $id;
  
      /**
       * @var string
       */
      private $title;
  </code></pre>
  
  <p>This is my repository Class</p>
  
  <pre><code>// Foo/NewsBundle/Repository/NewsRepository.php
  
  namespace Foo\NewsBundle\Repository;
  use Doctrine\ORM\EntityRepository;
  
  Class NewsRepository extends EntityRepository
  {
      public function test()
      {
          return "Nisarg";
      }
  }
  </code></pre>
  
  <p>And I am calling this <strong>test()</strong> function this wat from the controller</p>
  
  <pre><code>public function indexAction()
      {
  //        $news = $this-&gt;getDoctrine()
  //                -&gt;getRepository('FooNewsBundle:News')
  //                -&gt;findAll();
          $em = $this-&gt;getDoctrine()
                     -&gt;getManager();
  
          $news = $em-&gt;getRepository('FooNewsBundle:News')-&gt;test();
  
          if (!$news) {
              throw $this-&gt;createNotFoundException('No news found');
          }
          $build['news'] = $news;
          return $this-&gt;render('FooNewsBundle:Default:news_show_all.html.twig', $build);
      }
  </code></pre>