doctrine2 - Doctrine 2. How to force entity from proxy -
i have 3 entities:
/** * @orm\entity * @orm\table(name="table_a") */ class { /** * @orm\id * @orm\column(type="integer") * @orm\generatedvalue */ protected $id; /** * orm\onetomany(targetentity="b", mappedby="entitya") */ protected $entitiesb; /** * orm\onetomany(targetentity="c", mappedby="entitya") */ protected $entitiesc; /** * @orm\column(type="string") */ protected $name; } /** * @orm\entity * @orm\table(name="table_b") */ class b { /** * @orm\id * @orm\column(type="integer") * @orm\generatedvalue */ protected $id; /** * orm\manytoone(targetentity="a", inversedby="entitiesb") */ protected $entitya; /** * @orm\column(type="date") */ protected $date; } /** * @orm\entity * @orm\table(name="table_c") */ class c { /** * @orm\id * @orm\column(type="integer") * @orm\generatedvalue */ protected $id; /** * orm\manytoone(targetentity="a", inversedby="entitiesc") */ protected $entitya; /** * @orm\column(type="string") */ protected $description; } and have following situation:
$eb = $repositoryb->find(1); $ea = $eb->getentitya(); // $ea proxy $ec = new c(); $ec->setdescription('xxxxxxxxxx') ->setentitya($ea); this generate error because $ea proxy not entity. if try:
$eb = $repositoryb->find(1); $ea = $repositorya->find(1); $ec = new c(); $ec->setdescription('xxxxxxxxxx') ->setentitya($ea); will still error because once have fetched b entity automatically fetch proxy of entity. , when try fetch entity same identifier proxy doctrine return proxy object identity map because can not have 2 objects (one proxy , 1 entity) same db record.
so there way force retrieving entity proxy? or way set association, id not entity?
Comments
Post a Comment