无效 原则 2 映射:实体类'Downloads'映射无效



我正在尝试定义一个OneToMany双向(以避免ManyToMany和额外的表),我正在按照这里的文档所说的做(我想),但我肯定遗漏了一些东西,因为我在运行doctrine:schema:validate命令后收到了这个错误:

关联PlatformBundle\Entity\Downloads#标识符指的是不存在的拥有方字段PlatformBundle \Entity\identifier#Downloads。

这就是实体的样子(只是相关字段):

class Identifier
{
    /*
     * @var Downloads
     * @ORMManyToOne(targetEntity="Downloads", inversedBy="identifier")
     * @ORMJoinColumn(name="downloads_id", referencedColumnName="id")
     */
    protected $downloads;
}
class Downloads
{
    /**
     * @var Collection
     * @ORMOneToMany(targetEntity="Identifier", mappedBy="downloads")
     */
    protected $identifier;
    public function __construct() {
        $this->identifier = new ArrayCollection();
    }
}

这是一个将下载分配给多个标识符的关联。我做错了什么或错过了什么?

您在Identifier类中错误地输入了*

/**<- this one could cost you many hours :P
 * @var Downloads
 * @ORMManyToOne(targetEntity="Downloads", inversedBy="identifier")
 * @ORMJoinColumn(name="downloads_id", referencedColumnName="id")
 */
protected $downloads;

最新更新