【问题标题】:Not valid Doctrine2 mapping: The entity-class 'Downloads' mapping is invalid无效的 Doctrine2 映射:实体类“下载”映射无效
【发布时间】:2016-01-02 15:12:24
【问题描述】:

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

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

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

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();
    }
}

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

【问题讨论】:

  • 尝试使用FQCN进行targetEntity注解
  • @mblaettermann 没有变化,同样的结果,这很奇怪

标签: symfony doctrine-orm doctrine mapping


【解决方案1】:

您在Identifier 类中缺少*

/**<- 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;

【讨论】:

    猜你喜欢
    • 2013-12-03
    • 2013-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-11
    • 1970-01-01
    相关资源
    最近更新 更多