【发布时间】:2017-06-29 13:17:35
【问题描述】:
得到一个有点抽象的错误,存储库和实体关系映射似乎是正确的:
[Semantical Error] line 0, col 102 near 'v WHERE t.domainName': Error:
Class AppBundle\Entity\DocumentVersion has no association named document_versions
Document 实体:
/**
* @var Collection|DocumentVersion[]
*
* @ORM\OneToMany(targetEntity=DocumentVersion::class, mappedBy="document")
**/
private $document_versions;
DocumentVersion 实体:
/**
* @var Document
*
* @ORM\ManyToOne(targetEntity=\AppBundle\Entity\Document::class, inversedBy="document_versions")
* @JoinColumn(name="document_id", referencedColumnName="id")
**/
private $document;
一切似乎都被正确定义了。是什么导致了这个错误?
【问题讨论】:
-
看到您已经回答了您的问题。作为你的一个附带问题:你为什么将你的实体属性设为
private而不是protected?我总是让我的protected能够通过继承使用它们。想知道您是否出于特定原因使用private。 -
我倾向于留下
private直到我知道我想公开它们。
标签: symfony doctrine-orm repository-pattern