我有一个Symfony 2.4.x项目。Symfony2和Doctrine - 未定义索引
在那里,我有两个映射在一起的实体:会议和纸张。
每个会议都有论文和特定的会议,我想获得论文的数量。
对于这一点,在我的会议实体,我有:
/**
* @ORM\OneToMany(targetEntity="Paper", mappedBy="conference")
*/
protected $papers;
纸张我有实体:
/**
* @ORM\ManyToOne(targetEntity="Conference", inversedBy="papers")
* @ORM\JoinColumn(name="conference_id", referencedColumnName="id")
*/
protected $conference;
当我对Symfony2.0这个项目,一切运作良好,但现在我将它迁移到Symfony 2.4.x中,并且在尝试执行时遇到以下错误:
count($conf->getPapers()); // In the controller
{{ conf.papers | length }} // In the twig template
错误:
ContextErrorException: Notice: Undefined index: hash_key in /var/www/git/conference2.0-v2.4/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php line 121
编辑:下面是引擎收录的全类两个实体:
编辑2:这里有一些我试图解决这个问题所发现的新闻。另一个类别涉及:提交。
下面是代码:http://pastebin.com/bkdRtjdq
在课堂上提交,我有主键是HASH_KEY,而不是ID。
你能提供完整的论文和会议吗? – Flask
@Flask,我在使用pastebin的问题中添加了完整的代码。谢谢你的帮助。 –
你解决了这个问题吗? – Craig