我知道这是一个经常性的问题,而是创造200个实体和运行之间的OneToOne关系后的PHP应用程序/控制台学说:架构:验证“我得到这个错误:学说OneToOne我逼疯了
'[Mapping] FAIL - The entity-class 'HO\CisBundle\Entity\AffiliateSalesAccounts' mapping is invalid:
* The association HO\CisBundle\Entity\AffiliateSalesAccounts#affiliate refers to the inverse side field HO\HasoffersBundle\Entity\Affiliate#affiliateSalesAccounts which does not exist.'
这与两个实体的部分代码:
AffiliatesSalesAccount实体
namespace HO\CisBundle\Entity;
use HO\HasoffersBundle\Entity\Affiliate;
use Doctrine\ORM\Mapping as ORM;
/**
*
* @ORM\Table(name="AffiliateSalesAccounts")
* @ORM\Entity()
* @ORM\HasLifecycleCallbacks
*/
class AffiliateSalesAccounts {
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*
*/
private $id;
/**
* @var \HO\HasoffersBundle\Entity\Affiliate
*
* @ORM\OneToOne(targetEntity="HO\HasoffersBundle\Entity\Affiliate", inversedBy="affiliateSalesAccounts")
* @ORM\JoinColumn(name="affiliate_id", referencedColumnName="id")
*
*/
private $affiliate;
...
/**
* @param Affiliate $affiliate
*/
public function setAffiliate(Affiliate $affiliate)
{
$this->affiliate = $affiliate;
}
/**
* @return Affiliate
*/
public function getAffiliate()
{
return $this->affiliate;
}
}
加盟实体
namespace HO\HasoffersBundle\Entity;
use HO\CisBundle\Entity\AffiliateSalesAccounts;
use Doctrine\ORM\Mapping as ORM;
/**
*
* @ORM\Table(name="ho_Affiliate")
*/
class Affiliate
{
/**
* @var AffiliateSalesAccounts
*
* @ORM\OneToOne(targetEntity="HO\CisBundle\Entity\AffiliateSalesAccounts", mappedBy="affiliate")
*/
private $affiliateSalesAccounts;
....
/**
* @param \HO\CisBundle\Entity\AffiliateSalesAccounts $affiliateSalesAccounts
*/
public function setAffiliateSalesAccounts($affiliateSalesAccounts)
{
$this->affiliateSalesAccounts = $affiliateSalesAccounts;
}
/**
* @return \HO\CisBundle\Entity\AffiliateSalesAccounts
*/
public function getAffiliateSalesAccounts()
{
return $this->affiliateSalesAccounts;
}
}
我有两个实体之间的其他类似的OneToOne关系,它的伟大工程。我
有人能帮助我吗?
非常感谢..
试着改变你的'targetEntity'属性'targetEntity = “\ HO \ HasoffersBundle \实体\加盟”'和'targetEntity = “\ HO \ HasoffersBundle \实体\ AffiliateSalesAccounts”' , 分别。请注意前面的反斜杠以确保命名空间是正确的。 – sjagr
@sjagr,它不起作用,所有对实体的引用都可以正常工作,而不需要这个斜杠 – Averias
考虑将* @ORM \ Entity()添加到您的联盟实体。 – Cerad