[DDC-187] JOIN fails with inherited entities Created: 02/Dec/09  Updated: 03/Dec/09  Resolved: 03/Dec/09

Status: Closed
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.0-ALPHA3
Fix Version/s: 2.0-ALPHA4
Security Level: All

Type: Bug Priority: Critical
Reporter: Nico Kaiser Assignee: Roman S. Borschel
Resolution: Fixed Votes: 0
Labels: None


 Description   

"Entity\User\AbstractUser" is a base entity for user records, "Entity\User\Person" extends AbstractUser (Single Table inheritance in this case).
The "Setting" property is a OneToOne relation with another entity.

Now when I call this DQL:
SELECT u, t FROM Entity\User\AbstractUser u LEFT JOIN u.Setting t

The ObjectHydrator fails in line 276 ("if ( ! $relation->isOneToOne()) {"...) with "PHP Fatal error: Call to a member function isOneToOne() on a non-object in .../lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php".

It works when using the sub class for the query:
SELECT u, t FROM Entity\User\Person u LEFT JOIN u.Setting t



 Comments   
Comment by Nico Kaiser [ 02/Dec/09 ]

It seems like ObjectHydrator::_hydrateRow tries to find a _ce entry for AbstractUser (but _ce only holds entries for Person)...

Comment by Roman S. Borschel [ 02/Dec/09 ]

Does Setting use inheritance also? TopnewsSetting extends Setting? If so which inheritance type?

Comment by Roman S. Borschel [ 02/Dec/09 ]

Can we see the classes and their mappings? AbstractUser, User, Setting and TopnewsSetting. Then I can set up a test to reproduce it. Thanks!

Comment by Nico Kaiser [ 02/Dec/09 ]

Oh no I forgot to change TopnewsSetting to Setting in this report, there is no inheritance, just copy & paste bug.

Comment by Nico Kaiser [ 03/Dec/09 ]

Here are the classes and example code:

http://pastie.org/private/ljkiowarvm9trhdyug903q

Comment by Roman S. Borschel [ 03/Dec/09 ]

Successfully reproduced in our test suite and working on it.

Comment by Roman S. Borschel [ 03/Dec/09 ]

Should be fixed now. Thanks for reporting.

Generated at Mon Dec 22 23:36:18 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.