custom repository class in symfony2-Collection of common programming errors

Hi stackoverflow friends,

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?

Below is my repository class

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->getEntityManager()
            ->createQuery('SELECT p FROM symBundle:Register p ORDER BY p.name ASC')
            ->getResult();
    }


}

I called in my controller like this way

$em = $this->getDoctrine()->getEntityManager();
          $pro = $em->getRepository('symBundle:Register')
            ->findAllOrderedByName();

I got the below error

Undefined method 'findAllOrderedByName'. The method name must start with either findBy or findOneBy!

Do I have any mistake in my code ? Any mistake in creating repository class? did i need to use any class.