Php symfony映射错误:inverse和owning side字段不存在-尽管我在这两个类中都声明了它们
我按照symfony文档在两个classPhp symfony映射错误:inverse和owning side字段不存在-尽管我在这两个类中都声明了它们,php,symfony,doctrine-orm,Php,Symfony,Doctrine Orm,我按照symfony文档在两个classpartgroup(OneToMany)和partsub(manytone) 我在尝试验证条令模式时收到此错误消息 * The association Test\MyBundle\Entity\SpareParts\OemPartPosSubText#partgrpidk refers to the inverse side field Test\MyBundle\Entity\SpareParts\OemPartPosGrpText#partgrpidk
partgroup(OneToMany)
和partsub(manytone)
我在尝试验证条令模式时收到此错误消息
* 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.
及
我尝试了cache:clear
我到处找stackholder和google,但找不到任何解决方案 您的映射不正确。正确的映射应该如下所示:
/**
* 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;
...
(我还修改了你的财产名称)你能给我们看看你的实体吗?只有相关的关联,不需要完全复制。好的,我更新了代码
/**
* 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;
...