Uploaded image for project: '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
    • Status: Resolved
    • Priority: Major
    • Resolution: Cannot Reproduce
    • 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

        dalvarez Daniel Alvarez Arribas created issue -
        dalvarez 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 ]
        dalvarez 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
        dalvarez 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.
        dalvarez Daniel Alvarez Arribas made changes -
        Attachment DataObject.php [ 11096 ]
        Attachment Run.php [ 11097 ]
        Attachment Result.php [ 11098 ]
        dalvarez Daniel Alvarez Arribas made changes -
        Attachment InvoiceCreatorResult.php [ 11099 ]
        dalvarez Daniel Alvarez Arribas made changes -
        Attachment CommissionNoteCreatorResult.php [ 11100 ]
        Attachment ConsumerInvoiceExporterResult.php [ 11101 ]
        dalvarez Daniel Alvarez Arribas made changes -
        Attachment DataVersion.php [ 11102 ]
        dalvarez Daniel Alvarez Arribas made changes -
        Comment [ Entities involved in the inheritance hierarchy ]
        beberlei Benjamin Eberlei made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        beberlei Benjamin Eberlei made changes -
        Attachment DDC1390Test.php [ 11112 ]
        beberlei Benjamin Eberlei made changes -
        Workflow jira [ 13036 ] jira-feedback [ 14096 ]
        beberlei Benjamin Eberlei made changes -
        Workflow jira-feedback [ 14096 ] jira-feedback2 [ 15960 ]
        asm89 Alexander made changes -
        Status In Progress [ 3 ] Awaiting Testcase/Feedback [ 10000 ]
        beberlei Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 15960 ] jira-feedback3 [ 18205 ]
        Anonymous made changes -
        Status Awaiting Feedback [ 10000 ] In Progress [ 3 ]
        dalvarez Daniel Alvarez Arribas made changes -
        Status In Progress [ 3 ] Resolved [ 5 ]
        Resolution Cannot Reproduce [ 5 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved: