Reputation: 5424
I have a class
/**
* @ORM\Table(name="registration_number")
* @ORM\Entity
* @ORM\Entity(repositoryClass="PNC\MISDashboardBundle\Repositories\RegistrationNumberRepository")
* @ORM\HasLifecycleCallbacks
* @ORM\Entity@EntityListeners({"RegistrationNumberListener"})
*/
class RegistrationNumber {
}
and the repo class
namespace PNC\MISDashboardBundle\Repositories;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\NoResultException;
/**
* RegistrationNumberRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class RegistrationNumberRepository extends EntityRepository {
public function findByTotalMatches($keyword)
{
/* your awesome code block */
return 34;
}
}
and I am calling the method in this way;
$check = $em->getRepository('PNCMISDashboardBundle:RegistrationNumber')
->findTotalMatches(5);
But it says that;
Undefined method 'findTotalMatches'. The method name must start with either findBy or findOneBy!
I have built lot of other custom repo and works, i don't know that wrongs with this one. has anyone any hint what is wrong with this.
Upvotes: 2
Views: 860
Reputation: 13167
As said in comment,
Change :
/**
* @ORM\Table(name="registration_number")
* @ORM\Entity
* @ORM\Entity(repositoryClass="PNC\MISDashboardBundle\Repositories\RegistrationNumberRepository")
* @ORM\HasLifecycleCallbacks
* @ORM\Entity@EntityListeners({"RegistrationNumberListener"})
*/
class RegistrationNumber {
To :
/**
* @ORM\Table(name="registration_number")
* @ORM\Entity(repositoryClass="PNC\MISDashboardBundle\Repositories\RegistrationNumberRepository")
* @ORM\HasLifecycleCallbacks
* @ORM\EntityListeners({"RegistrationNumberListener"})
*/
class RegistrationNumber {
And it should works.
Upvotes: 3