symfony - Doctrine OneToMany relationship error -
i trying set manytoone/onetomany relationships on objects in database using doctrine (2.2.3+) via symfony2 (2.3.0) , getting strange error. here relevant parts of objects (many attributes 1 product):
/** * product * * @orm\table(name="product") * @orm\entity */ class product { /** * @var integer * * @orm\column(name="id", type="integer") * @orm\id * @orm\generatedvalue(strategy="auto") */ protected $id; ... /** * * @onetomany(targetentity="productattributes", mappedby="product") */ protected $product_attributes; public function __construct() { $this->product_attributes = new \doctrine\common\collections\arraycollection(); } } /** * productattributes * * @orm\table(name="product_attributes") * @orm\entity */ class productattributes { /** * @var integer * * @orm\column(name="pa_id", type="integer") * @orm\id * @orm\generatedvalue(strategy="auto") */ protected $pa_id; /** * @var integer * * @orm\column(name="product_id", type="integer") */ protected $product_id; ... /** * * @manytoone(targetentity="product", inversedby="product_attributes") * @joincolumn(name="product_id", referencedcolumnname="id") */ protected $product; }
when run the
php app/console doctrine:generate:entities bundlename
command following error:
[doctrine\common\annotations\annotationexception] [semantical error] annotation "@onetomany" in property lvmount\lvmbundle\entity\product::$product_attributes never imported. did maybe forget add "use" statement annotation?
i have looked through doctrine docs , don't see reference "use" statement manytoone/onetomany pairings. going on?
your annotations' syntax aren't complete.
you can see proper syntax doctrine annotation below.
/** * @orm\******** */
so, in case should following.
/** * @orm\onetomany(targetentity="productattributes", mappedby="product") */
you want fix annotations in productattributes
entity.
Comments
Post a Comment