Doctrine单表继承扩展自映射超类



我想做的是从映射的超类扩展一个表继承类,但当我尝试更新方案时,我会出现以下错误:

[条令\DBAL\Schema\SchemaException]
已在表"article_article"上定义了名为"uniq_efe84ad134ecb4e6"的索引。

我的层次结构:

内容(mappedSuperClass)<-文章(SingleTableHeritage)<-MyArticle

类别:

abstract class Content
{
    protected $id;
    public function getId()
    {
        return $this->id;
    }
}
class Article extends Content
{
}
class MyArticle extends Article
{
}

映射:

Content:
    type: mappedSuperclass
    id:
        id:
            type: integer
            id: true
            generator:
                strategy: AUTO

Article:
    type: entity
    table: article_article
    inheritanceType: SINGLE_TABLE
    discriminatorColumn:
        name: discr
        type: string
    discriminatorMap:
        article: Article
        my_article: MyArticle
MyArticle:
    type: entity

这里怎么了?

错误出现在mappedSuperclass上。Content类有一个oneToOne关系,这在上面的例子中没有,因为我试图使它更抽象。

Content:
    # ...
    oneToOne:
        route:
            targetEntity: Route

这似乎是学说试图再次为扩展类添加独特的密钥。我不知道这是对mappedSuperclass的限制还是只是一个bug,但我通过将oneToOne关系更改为manyToOne解决了这个问题,因为它几乎相同,但没有唯一的约束。

Content:
    # ...
    manyToOne:
        route:
            targetEntity: Route

最新更新