Eager loading of related entity in Symfony 2

前端 未结 2 1032
[愿得一人]
[愿得一人] 2021-01-04 04:06

There are three entities: Customer, Messages, Attachments.

The relationship between these entities is straight forward: A customer can have many messages and a messa

2条回答
  •  礼貌的吻别
    2021-01-04 04:27

    It sounds like expected behavior to me. The doctrine documentation seems to imply that eager fetching is only one level deep.

    According to the docs:

    Whenever you query for an entity that has persistent associations and these associations are mapped as EAGER, they will automatically be loaded together with the entity being queried and is thus immediately available to your application.

    http://doctrine-orm.readthedocs.org/en/latest/reference/working-with-objects.html#by-eager-loading

    The entity being queried in your case is customer and customer has eager on messages so messages are populated. Messages, however are not the object being queried, so attachments do not get loaded.

提交回复
热议问题