[英]Symfony / Doctrine: add annotiation to Attribute defined in 'MappedSuperclass'
编辑:我了解到,我的子类缺少注释(“这里只是一个ID”,与GreenLeaf相似)。 我现在的实际问题是,我不知道如何覆盖它,我无法使其正常工作。
原版的:
我刚刚将Symfony 2.0应用程序迁移到Symfony 2.2,并在dev-profiler中获得了有关单向一对多关联的“无效实体”信息。 当将控制台与
php console doctrine:schema:validate
我收到2条消息:
* The association \Entity\Watched#reference refers to the inverse side field \Entity\Reference#id which is not defined as association.
* The association \Entity\Watched#reference refers to the inverse side field \Entity\Reference#id which does not exist.
我认为这是错误的,因为'id'是在超类中定义的。 该应用程序仍然可以在旧数据库(使用Symfony 2.0创建)上正常运行。 这是我的课程(简体):
代码:全选
/**
* @ORM\MappedSuperclass
* @ORM\HasLifecycleCallbacks
*/
abstract class SuperclassAbstract {
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id = "";
// some fields more...
}
/**
* @ORM\Entity
* @ORM\Table(name="watched")
*/
class Watched extends SuperclassAbstract {
/**
* @ORM\ManyToOne(targetEntity="Reference", inversedBy="id")
* @ORM\JoinColumn(name="reference_id", referencedColumnName="id")
*/
protected $reference;
// some fields more...
}
/**
* @ORM\Entity
* @ORM\Table(name="reference")
*/
class Reference extends SuperclassAbstract {
// some fields more...
}
我绝对不能将学说看作是关系型数据库。...谢谢!
我在参考中添加了一个列表来处理关联的另一面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.