我的数据库结构如下:
工作:
评论:
工作评论 与 具有多对一关系工作 :
@ManyToOne(targetEntity="Work", inversedBy="comments")
工作 与 具有 OneToMany 关系工作评论 :
@OneToMany(targetEntity="WorkComment", mappedBy="work")
问题是 Doctrine 在更新模式时给了我这个错误:
[Doctrine\ORM\Mapping\MappingException]
It is illegal to put an inverse side one-to-many or many-to-many association on
mapped superclass 'Acme\...\AbstractImageWork#comments'.
我猜这与 MappedSuperclass 有关AbstractImageWork 卡在 之间工作 和 摄影作品 ,但我实际上并没有把这个关系放在 MappedSuperclass 上,而是放在 CTI 表上.. 那么为什么 Doctrine 会这样呢?
有任何想法吗?
最佳答案
在某些情况下,当您从标记为 @ORM\MappedSuperclass
的类继承时出现此类错误时,尝试从 更改您的属性访问级别私有(private) 至 protected
关于doctrine-orm - 教义2 : OneToMany on mapped superclass,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13124225/