[DDC-2032] DQL fails for Joined Inheritance with Associations on child classes Created: 15/Sep/12  Updated: 21/Sep/12  Resolved: 21/Sep/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: 2.3
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Philipp Dobrigkeit Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: dql
Environment:

Windows XAMPP



 Description   

I have the following object hierarchy:

Clazz A with Joined Table Inheritance
Clazz B extends A
Clazz C extends A with an association (n:1) to D
Clazz D

I am doing a DQL query 'SELECT u FROM A u'

If I just have As and Bs in the DB everything is fine. But I there is a C in there I get the following error:

Notice: Trying to get property of non-object in X:\Zend_Workspace\goalio_application\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\ObjectHydrator.php on line 479

Fatal error: Call to a member function fetch() on a non-object in X:\Zend_Workspace\goalio_application\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\ObjectHydrator.php on line 148

When I debug the _rsm of the Hydrator is null when trying to hydrate the row for C.

Any ideas?



 Comments   
Comment by Philipp Dobrigkeit [ 19/Sep/12 ]

Ok, it doesn't seem related to inheritance. Have the same problem now as well with a Join DQL query.

Foo (1:n) Bar
Bar (1:n) Baz

SELECT c FROM Foo c INNER JOIN c.bar cj WITH cj.id IN(1)

Gives me the same error as above when it tries to hydrate Bar

Comment by Philipp Dobrigkeit [ 21/Sep/12 ]

Ok, further investigations on my part have found the problem to be somewhere else entirely... Not sure yet if it is a bug, but the problem arises because during the hydration my application does another query, which uses the same hydrator object and thus does cleanup before the initial query is complete. That results in the _rsm being null when the original hydration continues. Will see if that can be fixed in my application.

Comment by Marco Pivetta [ 21/Sep/12 ]

Philipp Dobrigkeit this is known. You have to pass a custom hydrator to the new query if you use DQL during PostLoad events.

Generated at Fri Aug 01 09:53:16 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.