Status: In Progress
Affects Version/s: 2.1.1
Fix Version/s: None
Security Level: All
Environment:Debian Linux 6.0, MySQL 5.0.51a
Lazy loading does not work for the relationships of an instance of an entity, whose class inherits from another entity class.
Assume there are two entity classes, A and B, where A inherits from B.
Now let $a be an instance of A, e. g. the result of "SELECT a FROM \A WHERE a.id = 1".
Outputting $a will confirm it is a valid instance of a proxy object inheriting from A.
Assume that the database row corresponding to $a contains a non-null foreign key that actually links to an existing row in another table, corresponding to another entity instance of a different class.
Now, $a->someRelationship will always returns null in this scenario. I assume this is unintended behaviour, because clearly, the other entity should be lazily loaded on accessing it, and there is a value in the database.
The fetch annotation attribute on that relationship has not been explicitly set, so I assume it is set to the default value, which, according to the docs, should be "lazy".
The loading only fails when accessing the relationships of an entity instance, whose class inherits from another entity class. For entity instances, whose classes do not inherit from another entity class, lazy loading of their relationships works as expected.
I had a look at the proxy objects and verified that they are present and override the __get method with an implementation containing a call to the load() method. Still, the loading won't work for some reason.
This could be related to Bug
DDC-1389 (http://www.doctrine-project.org/jira/browse/DDC-1389) which also happens exclusively in an inheritance scenario. Maybe the current implementation of inheritance is generally wrong or incomplete.