i try create onetoone relation inheritance :
abstract class { } class a1 extends { } class a2 extends { } class f { /** * @orm\onetoone( ? ) */ private $object; // of type a1 or a2 }
i :
$f = $em->getrepository('mybundle:f')->findexample(); $object = $f->getobject(); // return instance of a1 or a2
what annotations should used?
if have unidirectional relation, means need f entity containing entity can use unidirectional relation:
class f { /** * @orm\onetoone(targetentity="a") * @orm\joincolumn(name="id_a", referencedcolumnname="id") */ private $a_object; }
note relation established a, means object of of a1 or a2. if need bidirectional , them should place annotation in too:
class { /** * @onetoone(targetentity="f", mappedby="a_object") **/ private $f_object; }
also note can inverse both annotations between f , a, depending of consider main side. check links , links more information.
hope you.
Comments
Post a Comment