doctrine/DoctrineMongoDBBundle — Issue #79: Couldn't find the custom method of my Repository
Author: scourgen
Created: 2012-02-22 14:20:41+00:00
State: open

I was following the guide of How to use mongodb with Symfony2(http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/index.html)

I have add a method just like the guide did

> // src/Acme/StoreBundle/Repository/ProductRepository.php
> namespace Acme\StoreBundle\Repository;
> use Doctrine\ODM\MongoDB\DocumentRepository;
> class ProductRepository extends DocumentRepository
> {
> public function findAllOrderedByName()
> {
> return $this->createQueryBuilder()
> ->sort('name', 'ASC')
> ->getQuery()
> ->execute();
> }
>}

But When I want use this method:

> $product = $this->get('doctrine.odm.mongodb.document_manager')
->getRepository('AcmeStoreBundle:Product')
->findAllOrderedByName();

I got a Undefined method error by symfony:

> Undefined method 'findAllOrderedByName'. The method name must start with either findBy or findOneBy!
500 Internal Server Error - BadMethodCallException