2017-04-04 12 views
0

私は直接ではなく、2 entites間の多対多の関係をクレタしたいが、二重manyToOne関係で第3のエンティティを使用して動作しません。教義は、第3のエンティティの上に多対多を作成し、適切

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()

方法を持っていませんか?

答えて

1

関係を所有している当事者のみをマッピングしました。双方向の関係を確立する必要があります。

すべてがここで説明されています http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/association-mapping.html#one-to-many-bidirectionalhttp://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/association-mapping.html#many-to-many-bidirectional

すべて:)

+1

の神私のああ、私は、おかげで、このようなばか者だったのですそれ – Asara

関連する問題