doctrine创建manyToMany超过第三个实体不能正常工作

时间:2017-04-04 16:21:53

标签: symfony doctrine entity

我想通过使用具有double manyToOne关系的第三个实体来创建两个entite之间的多个关系:

AppBundle\Entity\AttributeKey:
    type: entity
    table: attribute_keys
    repositoryClass: AppBundle\Repository\AttributeKeyRepository
    id:
        id:
            type: integer
            id: true
            generator:
                strategy: AUTO
    fields:
        label:
            type: string
            length: 255
            unique: true
        sort:
            type: integer
AppBundle\Entity\AttributeValue:
    type: entity
    table: attribute_values
    repositoryClass: AppBundle\Repository\AttributeValueRepository
    id:
        id:
            type: integer
            id: true
            generator:
                strategy: AUTO
    fields:
        label:
            type: string
            length: 255
            unique: true
AppBundle\Entity\AttributeKeyValue:
    type: entity
    table: attribute_keys_values
    repositoryClass: AppBundle\Repository\AttributeKeyValueRepository
    manyToOne:
        attributeKey:
            targetEntity: AttributeKey
        attributeValue:
            targetEntity: AttributeValue
    manyToMany:
        documents:
          targetEntity: Document
          mappedBy: attributes    
    id:
        id:
            type: integer
            id: true
            generator:
                strategy: AUTO

在数据库中,一切看起来都很好,外键是正确构建的。但是,由学说生成的AttributeKey实体不包含方法getValues(),而AttributeValue没有方法getKeys()addKey()

我做错了什么?