symfony2 - Doctrine EntityRepository for extended Entity -



symfony2 - Doctrine EntityRepository for extended Entity -

i having problem mapping custom entity repository entity extended entity.

base entity:

/** * user entity * * @orm\table(name="user") * @orm\entity * * @orm\inheritancetype("single_table") * @orm\discriminatorcolumn(name="user_type", type="string") * @orm\discriminatormap({"user" = "user", "client" = "client"}) */ class user { }

extended entity:

/** * client entity * * @orm\entity(repositoryclass="acme\appbundle\entity\clientrepository") */ class client extends user { }

repository:

namespace acme\appbundle\entity; utilize doctrine\orm\entityrepository; /** * clientrepository */ class clientrepository extends entityrepository { /* * method returns resultset * empty simplification */ public function getclientswithactivecampaign(\datetimeinterface $date = null) {} }

calling repository:

$clients = $this->getdoctrine()->getrepository('acmeappbundle:client')->getclientswithactivecampaign();

but when calling custom method on clientrepository get:

undefined method 'getclientswithactivecampaign'. method name must start either findby or findoneby!

so seems doctrine doesn't know custom repository.

thinking this, entity manager missing , why cannot find repository. in controller/service, use:

$em = $em= $this->getdoctrine()->getmanager(); $clients = $em->getrepository('acmeappbundle:client')->getclientswithactivecampaign();

the $clients variable should populated now, or @ to the lowest degree different error. getclientswithactivecampaign function should run.

symfony2 doctrine2

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -