Doctrine 2 mapping referencing unique key

后端 未结 2 909
无人及你
无人及你 2021-01-02 11:27

Basic question:

Is it possible to map an association using Doctrine referencing not a primary but only a unique key?

Extended Versio

相关标签:
2条回答
  • 2021-01-02 11:45

    Just like following references, Doctrine does not support this type of mapping

    http://www.doctrine-project.org/jira/browse/DDC-1269

    http://www.doctrine-project.org/jira/browse/DDC-1114

    I think it will be helps to you.

    0 讨论(0)
  • 2021-01-02 11:57

    Since I did not get any answer yet I did another research today and I found the answer to my own question through the Doctrine mailing lists forum. Seems like I just searched for the wrong keywords...

    Doctrine 2 unfortunately does not support it. What a pity! :(

    From the Doctrine documentation: https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/limitations-and-known-issues.html#join-columns-with-non-primary-keys

    It is not possible to use join columns pointing to non-primary keys. Doctrine will think these are the primary keys and create lazy-loading proxies with the data, which can lead to unexpected results. Doctrine can for performance reasons not validate the correctness of this settings at runtime but only through the Validate Schema command.

    Similar question: Is it possible to reference a column other than 'id' for a JoinColumn?

    0 讨论(0)
提交回复
热议问题