Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1390

Lazy loading does not work for the relationships of an entity instance, whose class inherits from another entity class

    Details

    • Type: Bug Bug
    • Status: In Progress
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.1.1
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None
    • Environment:
      Debian Linux 6.0, MySQL 5.0.51a

      Description

      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.

      1. DataObject.php
        1 kB
        Daniel Alvarez Arribas
      2. Result.php
        2 kB
        Daniel Alvarez Arribas
      3. Run.php
        2 kB
        Daniel Alvarez Arribas
      4. InvoiceCreatorResult.php
        0.8 kB
        Daniel Alvarez Arribas
      5. CommissionNoteCreatorResult.php
        0.9 kB
        Daniel Alvarez Arribas
      6. ConsumerInvoiceExporterResult.php
        0.3 kB
        Daniel Alvarez Arribas
      7. DataVersion.php
        1 kB
        Daniel Alvarez Arribas
      8. DDC1390Test.php
        2 kB
        Benjamin Eberlei

        Activity

        Hide
        Benjamin Eberlei added a comment -

        No i only checked the validity of mappings with the original data. If you could setup a testcase that would be really great.

        Show
        Benjamin Eberlei added a comment - No i only checked the validity of mappings with the original data. If you could setup a testcase that would be really great.
        Hide
        Daniel Alvarez Arribas added a comment -

        I will set up a test case and upload it. I'll see if I can do it one of the next evenings.

        Show
        Daniel Alvarez Arribas added a comment - I will set up a test case and upload it. I'll see if I can do it one of the next evenings.
        Hide
        Benjamin Eberlei added a comment -

        I tried again, also extended DDC-1390, but it was impossible for me to reproduce this. I ran this against master, 2.1.x and 2.1.1 specifically.

        Show
        Benjamin Eberlei added a comment - I tried again, also extended DDC-1390 , but it was impossible for me to reproduce this. I ran this against master, 2.1.x and 2.1.1 specifically.
        Hide
        Daniel Alvarez Arribas added a comment - - edited

        Sorry, I got swamped with work. Now I am working on this dedicatedly, testing against the latest release. Will let you know once I have a testcase.

        Show
        Daniel Alvarez Arribas added a comment - - edited Sorry, I got swamped with work. Now I am working on this dedicatedly, testing against the latest release. Will let you know once I have a testcase.
        Hide
        Benjamin Eberlei added a comment -

        Good to hear, thanks for the persistent work on this.

        Show
        Benjamin Eberlei added a comment - Good to hear, thanks for the persistent work on this.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Daniel Alvarez Arribas
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: