0
我有两个实体一个是主要的,第二个是额外的,他们以OneToOne的形式加入。我不会让所有的,我认为这是没有必要的:Symfony2,Doctrine,在关系中的空实体
apiKey
/**
* @ORM\OneToOne(targetEntity="Eve\ApiBundle\Entity\Account\apiKeyInfo", inversedBy="apiKey_byKeyID")
* @ORM\JoinColumn(name="keyID", referencedColumnName="keyID")
*/
private $apiKeyInfo_byKeyID;
public function get_apiKeyInfo_byKeyID()
{
return $this->apiKeyInfo_byKeyID;
}
apiKeyInfo
/**
* @ORM\OneToOne(targetEntity="Eve\ProfileBundle\Entity\apiKey", mappedBy="apiKeyInfo_byKeyID")
*/
private $apiKey_byKeyID;
public function get_apiKey_byKeyID()
{
return $this->apiKey_byKeyID;
}
/**
* @ORM\Column(name="type", type="string", length=255)
*/
private $type;
/**
* @param string $type
* @return apiKeyInfo
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* @return string
*/
public function getType()
{
return $this->type;
}
关系我称之为树枝(apiKey在PHP部分悟天)
apiKey.get_apiKeyInfo_byKeyID.type
它工作正常,当数据库表装满数据,但是当“apiKeyInfo”表不具有相同keyid的扔了我的异常:
Entity was not found.
我明白为什么,因为它无法找到具有相同keyid的条目..但我不知道该如何处理。
所以问题是...... 我怎样才能使这个关系的结果可以为空?