What is the difference between inversedBy and mappedBy?

后端 未结 4 1935
[愿得一人]
[愿得一人] 2020-12-04 05:26

I am developing my application using Zend Framework 2 and Doctrine 2.

While writting annotations, I am unable to understand the difference between mappedBy

4条回答
  •  长情又很酷
    2020-12-04 06:09

    • mappedBy has to be specified on the inversed side of a (bidirectional) association
    • inversedBy has to be specified on the owning side of a (bidirectional) association

    from doctrine documentation:

    • ManyToOne is always the owning side of a bidirectional assocation.
    • OneToMany is always the inverse side of a bidirectional assocation.
    • The owning side of a OneToOne assocation is the entity with the table containing the foreign key.

    See https://www.doctrine-project.org/projects/doctrine-orm/en/latest/reference/unitofwork-associations.html

提交回复
热议问题