Closed guillaumeoriol closed 12 years ago
At the moment, Persister#fetchAll
returns an array of entities. If we use this method to load collection-valued properties, we face a problem: it may not be appropriate to our needs and would not conform to ORM requirements. Doctrine gives the following explanatation in the Association Mapping chapter:
[...] Unfortunately, PHP arrays, while being great for many things, do not make up for good collections of business objects, especially not in the context of an ORM. The reason is that plain PHP arrays can not be transparently extended / instrumented in PHP code, which is necessary for a lot of advanced ORM features. [...]
What is the best solution? Have a separate method to return a collection (instead of an array) or change fetchAll
API to return a collection?
Say we have a Person entity with the following properties:
and a Permission entity with the following properties:
At the moment,
Persister#loadEntity
does the following:Table#loadEntity
to load the domain objectWith the example above, when a person is retrieved,
Table#loadEntity
of that person will, in turn, retrieve the related permissions. Each permission will be loaded and, to do so, it will try to load the related person. It should retrieve the person from the map (as it is the already retrieved person) but won't as the domain object will be put into the map at the end of the process.