为级联配置的Symfony实体号
谁能帮我解释一下我做错了什么?我尝试设置与文件相关的实体。它是关于供应商和库存的 我的股票实体看起来像为级联配置的Symfony实体号,symfony,entity,cascade,Symfony,Entity,Cascade,谁能帮我解释一下我做错了什么?我尝试设置与文件相关的实体。它是关于供应商和库存的 我的股票实体看起来像 /** * @ORM\ManyToOne(targetEntity="PrClientBundle\Entity\Lieferanten") * @ORM\JoinColumn(name="liefer_id", referencedColumnName="id") * @var lieferant */ private $lieferant; 我还使用getter和setter,如
/**
* @ORM\ManyToOne(targetEntity="PrClientBundle\Entity\Lieferanten")
* @ORM\JoinColumn(name="liefer_id", referencedColumnName="id")
* @var lieferant
*/
private $lieferant;
我还使用getter和setter,如下所示
/**
* Set lieferant
*
* @param \PrClientBundle\Entity\Lieferanten $lieferant
* @return Leadbase
*/
public function setLieferant(\PrClientBundle\Entity\Lieferanten $lieferant = null)
{
$this->lieferant = $lieferant;
return $this;
}
/**
* Get lieferant
*
* @return \PrClientBundle\Entity\Lieferanten
*/
public function getLieferant()
{
return $this->lieferant;
}
导入新库存项目时,如:
$lead->setLieferant($lieferant);
我收到了以下我真的不明白的错误信息:(
如果你能帮我理解我做错了什么,那就太好了。你需要
$em->persist($lieferant);
OMG.Thnks。我做了以下几点:$em->clear();每次persist之后,我的供应商数据也被删除了:(非常感谢你的提示。你需要$em->persist($lieferant)
OMG.Thnks.我做了以下几件事:$em->clear();每次坚持之后,我的供应商数据也随之消失:(非常感谢你的提示。
[Doctrine\ORM\ORMInvalidArgumentException]
A new entity was found through the relationship 'PrLeadBundle\Entity\Leadbase#lieferant' that was not configured to cascade persist operations for entity: PrClientBundle\Enti
ty\Lieferanten@000000002a45dae80000000002f826ff. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this
association in the mapping for example @ManyToOne(..,cascade={"persist"}). If you cannot find out which entity causes the problem implement 'PrClientBundle\Entity\Lieferante
n#__toString()' to get a clue.