gpt4 book ai didi

php - symfony 映射错误 : inverse and owning side field field doesnot exist - even though I declared them in both the classes

转载 作者:搜寻专家 更新时间:2023-10-31 21:55:56 25 4
gpt4 key购买 nike

我按照 symfony 文档 here 创建了两个类 partgroup(OneToMany)partsub(ManyToOne) 之间的双向关系

当我尝试验证原则模式时收到此错误消息

* The association Test\MyBundle\Entity\SpareParts\OemPartPosSubText#partgrpidk refers to the inverse side field Test\MyBundle\Entity\SpareParts\OemPartPosGrpText#partgrpidk which is not defined as association.

* The association Test\MyBundle\Entity\SpareParts\OemPartPosSubText#partgrpidk refers to the inverse side field Test\MyBundle\Entity\SpareParts\OemPartPosGrpText#partgrpidk which does not exist.

[Mapping]  FAIL - The entity-class 'Test\MyBundle\Entity\SpareParts\OemPartPosGrpText' mapping is invalid:
* The association Test\MyBundle\Entity\SpareParts\OemPartPosGrpText#partsubidk refers to the owning side field Test\MyBundle\Entity\SpareParts\OemPartPosSubText#partsubidk which is not defined as association, but as field.

Code

我试过 cache:clear

我到处找stackholder和谷歌但找不到任何解决方案。

最佳答案

您的映射不正确。正确的映射应该是这样的:

/**
* OemPartPosGrpText
*
* @ORM\Table(name="oem_PartPosGrpText")
* @ORM\Entity(repositoryClass="Test\MyBundle\Entity\SpareParts\Repo\SparePartMenuRepository")
*
*/
class OemPartPosGrpText
{

/**
* @var integer
*
* @ORM\Column(name="PartGrpIDK", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $partgrpidk;

/**
* @ORM\OneToMany(targetEntity="partSubText", mappedBy="partgrp")
*/
private $partsubs;

...


/**
* oemPartPosSubText
*
* @ORM\Table(name="oem_PartPosSubText")
* @ORM\Entity(repositoryClass="Test\MyBundle\Entity\SpareParts\Repo\SparePartMenuRepository")
*/

class partSubText
{

/**
* @var integer
*
* @ORM\Column(name="PartSubIDK", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $partsubidk;

/**
* @ORM\ManytoOne(targetEntity="OemPartPosGrpText",inversedBy="partsubs")
* @ORM\JoinColumn(name="PartGrpIDK", referencedColumnName="PartGrpIDK")
*/
private $partgrp;

...

(我也修改了你的属性名)

关于php - symfony 映射错误 : inverse and owning side field field doesnot exist - even though I declared them in both the classes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33755392/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com