title: custom repository class in symfony2
body: <p>I'm new in symfony2.I created a repository class when I created an entity class through command line.But I couldn't access my custom functions in that repository class. how to create custom repository class in symfony2? Can anybody give me a step by step explanation from scratch with some sample code?</p>
  
  <p>Below is my repository class</p>
  
  <pre><code>namespace Mypro\symBundle\Entity;
  
  use Doctrine\ORM\EntityRepository;
  
  /**
   * RegisterRepository
   * This class was generated by the Doctrine ORM. Add your own custom
   * repository methods below.
   */
  class RegisterRepository extends EntityRepository
  {
  
  
      public function findAllOrderedByName()
      {
          return $this-&gt;getEntityManager()
              -&gt;createQuery('SELECT p FROM symBundle:Register p ORDER BY p.name ASC')
              -&gt;getResult();
      }
  
  
  }
  </code></pre>
  
  <p>I called in my controller like this way</p>
  
  <pre><code>$em = $this-&gt;getDoctrine()-&gt;getEntityManager();
            $pro = $em-&gt;getRepository('symBundle:Register')
              -&gt;findAllOrderedByName();
  </code></pre>
  
  <p>I got the below error </p>
  
  <pre><code>Undefined method 'findAllOrderedByName'. The method name must start with either findBy or findOneBy!
  </code></pre>
  
  <p>Do I have any mistake in my code ? Any mistake in creating repository class? did i need to use any class.</p>