That's an ORM limitation that you are hitting. The ORM doesn't really know
(yet? nobody working on this, so far) how to deal with multiple levels of
identity indirection, at the moment.

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

On Thu, Sep 29, 2016 at 6:15 PM, Maksim Borisov <[email protected]>
wrote:

> Trying to build relations using this guide http://docs.doctrine-project.
> org/projects/doctrine-orm/en/latest/tutorials/composite-primary-keys.html
> Here is my entities mappings:
> # Simple entity with no foreign keys
> Region:
>     id:
>         id:                                     { type: bigint, id: true,
> generator: { strategy: IDENTITY } }
>     fields:
>          # some fields
>
> # Domain has 1-to-1 relation to region, and Region#id used as Domain
> identifier
> Domain:
>     id:
>         Region:                                 { associationKey: true }
>     fields:
>          # some fields
>     oneToOne:
>         Region:
>             targetEntity:                       Region
>             joinColumn:                         { name: departure_city_id,
> referencedColumnName: id }
>
> # Then I want to create many-to-many relation between Domain and Region
> (this is logistic information about what Regions are available for each
> Domain)
> # As described in guide "Use-Case 3: Join-Table with Metadata"
> DomainRegion:
>      id:
>         Domain:                                 { associationKey: true }
>         Region:                                 { associationKey: true }
>     fields:
>         # some fields
>     manyToOne:
>         Domain:
>             targetEntity:                       Domain
>             #inversedBy:                         DomainRegions
>             joinColumn:                         { name: domain_id,
> referencedColumnName: departure_city_id }
>         Region:
>             targetEntity:                       Region
>             #inversedBy:                        DomainRegions
>             joinColumn:                         { name: region_id,
> referencedColumnName: id }
>     lifecycleCallbacks:                         {  }
>
>
> This mappings had no errors during entities generation and even used in
> code. The only thing than troubles me - is validation, then I call validate
> command, i get messages like this:
> ** Cannot map association 'DomainRegion#Domain as identifier, because the
> target entity 'Domain' also maps an association as identifier.*
>
> It looks for me as mapping issue, otherwise tell me where I was wrong.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "doctrine-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/doctrine-user.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to