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. CommissionNoteCreatorResult.php
        0.9 kB
        Daniel Alvarez Arribas
      2. ConsumerInvoiceExporterResult.php
        0.3 kB
        Daniel Alvarez Arribas
      3. DataObject.php
        1 kB
        Daniel Alvarez Arribas
      4. DataVersion.php
        1 kB
        Daniel Alvarez Arribas
      5. DDC1390Test.php
        2 kB
        Benjamin Eberlei
      6. InvoiceCreatorResult.php
        0.8 kB
        Daniel Alvarez Arribas
      7. Result.php
        2 kB
        Daniel Alvarez Arribas
      8. Run.php
        2 kB
        Daniel Alvarez Arribas

        Activity

        Daniel Alvarez Arribas created issue -
        Daniel Alvarez Arribas made changes -
        Field Original Value New Value
        Affects Version/s 2.1.1 [ 10153 ]
        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 instances of entity instances, whose class inherits from another entity class. For instances of entity classes that 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.
        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 instances of entity instances, whose class inherits from another entity class. For instances of entity classes that 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.
        Component/s ORM [ 10012 ]
        Daniel Alvarez Arribas made changes -
        Summary  Lazy loading does not work for the relationships of an instance of an entity, whose class inherits from another entity class  Lazy loading does not work for the relationships of an entity instance, whose class inherits from another entity class
        Daniel Alvarez Arribas made changes -
        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 instances of entity instances, whose class inherits from another entity class. For instances of entity classes that 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.
        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.
        Daniel Alvarez Arribas made changes -
        Attachment DataObject.php [ 11096 ]
        Attachment Run.php [ 11097 ]
        Attachment Result.php [ 11098 ]
        Daniel Alvarez Arribas made changes -
        Attachment InvoiceCreatorResult.php [ 11099 ]
        Daniel Alvarez Arribas made changes -
        Attachment CommissionNoteCreatorResult.php [ 11100 ]
        Attachment ConsumerInvoiceExporterResult.php [ 11101 ]
        Daniel Alvarez Arribas made changes -
        Attachment DataVersion.php [ 11102 ]
        Daniel Alvarez Arribas made changes -
        Comment [ Entities involved in the inheritance hierarchy ]
        Benjamin Eberlei made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Benjamin Eberlei made changes -
        Attachment DDC1390Test.php [ 11112 ]
        Benjamin Eberlei made changes -
        Workflow jira [ 13036 ] jira-feedback [ 14096 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback [ 14096 ] jira-feedback2 [ 15960 ]
        Alexander made changes -
        Status In Progress [ 3 ] Awaiting Testcase/Feedback [ 10000 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 15960 ] jira-feedback3 [ 18205 ]
        made changes -
        Status Awaiting Feedback [ 10000 ] In Progress [ 3 ]

          People

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

            Dates

            • Created:
              Updated: