V
V
Vadim Ivanenko2014-11-25 15:00:14
Doctrine ORM
Vadim Ivanenko, 2014-11-25 15:00:14

Why Doctrine ORM generates Entities in some cases Unidirectional and in others Bidirectional?

I did not particularly delve into the annotations of the Doctrine. I just generate classes and set/get methods.
There are two parts of the database. Both have seemingly identical tables and 1 : N relationships. Using doctrine-module orm:convert-mapping creates unidirectional relationships in one module and bidirectional relationships in the other.
On what does such behavior of the Doctrine depend? What should be the structure of the database to generate Entities with bidirectional relationships?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
keltanas, 2014-12-04
@supra7sky

Entity generation is advisory in nature to make routine work easier for the programmer.
After generation, you must independently correct the configuration of entities, including all relationships, in accordance with your requirements.
I hope you know how doctrine differs from, for example, ar in yii?
Doctrine works from the schema described in the entity config, not from the database schema. On the contrary, the database schema is generated based on the entity config.

Q
Quber, 2014-11-25
@Quber

This behavior depends directly on how you specify the links. If you specify Bidirectional then it will be so, if Unidirectional then so. No magic.
See the documentation for more details, everything is clearly written and chewed there docs.doctrine-project.org/en/latest/reference/asso...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question