我正在努力创建两个实体之间的ManyToOne
关系。根据文档,这个我的代码应该足以创建有效的ManyToOne关系,但我不断收到下面描述的错误。我必须遗漏一些明显的东西,但我不确定它是什么。
Project有很多RemoteVotes。
应用程序抛出的错误是:
Doctrine\ORM\Mapping\MappingException
The target-entity App\Model\RemoteVote cannot be found in 'App\Model\Project#remoteVotes'.
RemoteVote.php模型的相关部分:
namespace App\Model;
/**
* @ORM\Entity
* @ORM\Table(name="remote_votes")
*/
class RemoteVote extends BaseEntity {
...
/**
* @ORM\ManyToOne(targetEntity="Project", inversedBy="remoteVotes")
* @ORM\JoinColumn(name="project_id", referencedColumnName="id")
*/
protected $project;
...
Project.php模型的相关位:
namespace App\Model;
/**
* @ORM\Entity
* @ORM\Table(name="projects")
*/
class Project extends BaseEntity
{
public function __construct()
{
$this->remoteVotes = new ArrayCollection();
}
...
/**
* @ORM\OneToMany(targetEntity="RemoteVote", mappedBy="project", cascade={"persist"})
*/
protected $remoteVotes;
...
提前致谢。
答案 0 :(得分:0)
可悲的是,这不是Doctrine问题,而是缓存框架的问题。删除缓存解决了它。