无效的 Doctrine2 映射:实体-class 'Downloads' 映射无效
Not valid Doctrine2 mapping: The entity-class 'Downloads' mapping is invalid
我正在尝试定义一个 OneToMany
双向(以避免 ManyToMany
和额外的 table)并且我正在做(我认为)正如文档所说 here但肯定我遗漏了一些东西,因为我在 运行 doctrine:schema:validate
命令后收到此错误:
The association PlatformBundle\Entity\Downloads#identifier refers to the owning side field PlatformBundle\Entity\Identifier#downloads which does not exist.
这是实体的样子(只是相关字段):
class Identifier
{
/*
* @var Downloads
* @ORM\ManyToOne(targetEntity="Downloads", inversedBy="identifier")
* @ORM\JoinColumn(name="downloads_id", referencedColumnName="id")
*/
protected $downloads;
}
class Downloads
{
/**
* @var Collection
* @ORM\OneToMany(targetEntity="Identifier", mappedBy="downloads")
*/
protected $identifier;
public function __construct() {
$this->identifier = new ArrayCollection();
}
}
这是一个下载分配给多个标识符的关联。我在这里做错了什么或遗漏了什么?
您在 Identifier
Class 中缺少一个 *
:
/**<- this one could cost you many hours :P
* @var Downloads
* @ORM\ManyToOne(targetEntity="Downloads", inversedBy="identifier")
* @ORM\JoinColumn(name="downloads_id", referencedColumnName="id")
*/
protected $downloads;
我正在尝试定义一个 OneToMany
双向(以避免 ManyToMany
和额外的 table)并且我正在做(我认为)正如文档所说 here但肯定我遗漏了一些东西,因为我在 运行 doctrine:schema:validate
命令后收到此错误:
The association PlatformBundle\Entity\Downloads#identifier refers to the owning side field PlatformBundle\Entity\Identifier#downloads which does not exist.
这是实体的样子(只是相关字段):
class Identifier
{
/*
* @var Downloads
* @ORM\ManyToOne(targetEntity="Downloads", inversedBy="identifier")
* @ORM\JoinColumn(name="downloads_id", referencedColumnName="id")
*/
protected $downloads;
}
class Downloads
{
/**
* @var Collection
* @ORM\OneToMany(targetEntity="Identifier", mappedBy="downloads")
*/
protected $identifier;
public function __construct() {
$this->identifier = new ArrayCollection();
}
}
这是一个下载分配给多个标识符的关联。我在这里做错了什么或遗漏了什么?
您在 Identifier
Class 中缺少一个 *
:
/**<- this one could cost you many hours :P
* @var Downloads
* @ORM\ManyToOne(targetEntity="Downloads", inversedBy="identifier")
* @ORM\JoinColumn(name="downloads_id", referencedColumnName="id")
*/
protected $downloads;