doctrine orm manytoone multi-column join奇怪的错误

时间:2017-05-24 01:31:09

标签: symfony doctrine-orm doctrine

我在Symfony中使用doctrine ORM“增强”具有引用完整性的遗留数据模型。

我有这个架构yml定义

AppBundle\Entity\QualityDataItems:
    type: entity
    table: quality_data_items
    id:
        rfi_id:
            type: integer
            options:
                unsigned: false
            id: true
        rfi_type:
            type: string
            length: 10
            id: true
    manyToOne:
        RfiPeople:
            targetEntity: QualityDataItemsPeople
            joinColumn:
                rfi_type:
                    referencedColumnName: rfi_type_id
                rfi_id:
                    referencedColumnName: rfi_id
    fields:
        issue_text:
            type: text
            nullable: true
            length: 65535
        response_text:
            type: text
            nullable: true
            length: 65535
        resolution_text:
            type: text
            nullable: true
            length: 65535
        add_to_report:
            type: integer
            nullable: true
            options:
                unsigned: false
                default: '0'
        add_to_report_date:
            type: datetime
            nullable: true
        issue_cause:
            type: integer
            nullable: true
        issue_type:
            type: integer
            nullable: true
        issue_sub_type:
            type: integer
            nullable: true
        linked_to_id:
            type: integer
            nullable: true
        status_id:
            type: integer
            nullable: true

AppBundle\Entity\QualityDataItemsPeople:
    type: entity
    table: quality_data_items_people
    id:
        rfi_ppl_idx:
            type: integer
            generator: { strategy: AUTO }
    manyToOne:
        RfiJob:
            targetEntity: RfiJob
            joinColumn:
                name: rfi_id
                referencedColumnName: rfi_id
        RfiType:
            targetEntity: RfiType
            joinColumn:
                name: rfi_type
                referencedColumnName: rfi_type_id
    fields:
        rfi_id:
            type: integer
        rfi_type:
            type: string
            length: 10
        user_id:
            type: integer

当我跑

bin/console doctrine:generate:entities AppBundle
bin/console doctrine:schema:update --dump-sql

我明白了:

[Doctrine\ORM\ORMException] Column name 'id' referenced for relation from AppBundle\Entity\QualityDataItems towards AppBundle\Entity\QualityDataItemsPeople does not exist. 

这些表中没有名为id的列。我还删除了实体类,以确保其中没有任何内容

1 个答案:

答案 0 :(得分:0)

要么没有记录或支持,但你可以尝试一下吗?

manyToOne:
    RfiPeople:
        targetEntity: QualityDataItemsPeople
        joinColumns:
          - joinColumn:
                name:                 rfi_type_id
                referencedColumnName: rfi_type_id
          - joinColumn:
                name:                 rfi_id
                referencedColumnName: rfi_id