Q:

doctrine create manyToMany over third entity does not work properly

I want to creta a manyToMany relation between two entites not directly but by using a third entity with double manyToOne relations:
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

In the database everything looks fine, the foreign keys are properly built.  But the AttributeKey Entity that is generated by doctrine does not contain a method getValues() and AttributeValue does not have the method getKeys() or addKey()
What did I do wrong? 

A:

You mapped only the party that owns the relationship.  You need to set up a two-way relationship. 
Everything is explained here :
http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/association-mapping.html#one-to-many-bidirectional
and
http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/association-mapping.html#many-to-many-bidirectional
That's all :)

