DDC-187: JOIN fails with inherited entities #230

Closed
opened 2026-01-22 12:31:38 +01:00 by admin · 8 comments
Owner

Originally created by @doctrinebot on GitHub (Dec 2, 2009).

Jira issue originally created by user nicokaiser:

"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

Originally created by @doctrinebot on GitHub (Dec 2, 2009). Jira issue originally created by user nicokaiser: "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`
admin added the Bug label 2026-01-22 12:31:38 +01:00
admin closed this issue 2026-01-22 12:31:39 +01:00
Author
Owner

@doctrinebot commented on GitHub (Dec 2, 2009):

Comment created by nicokaiser:

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

@doctrinebot commented on GitHub (Dec 2, 2009): Comment created by nicokaiser: It seems like ObjectHydrator::*hydrateRow tries to find a _ce entry for AbstractUser (but *ce only holds entries for Person)...
Author
Owner

@doctrinebot commented on GitHub (Dec 2, 2009):

Comment created by romanb:

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

@doctrinebot commented on GitHub (Dec 2, 2009): Comment created by romanb: Does Setting use inheritance also? TopnewsSetting extends Setting? If so which inheritance type?
Author
Owner

@doctrinebot commented on GitHub (Dec 2, 2009):

Comment created by romanb:

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

@doctrinebot commented on GitHub (Dec 2, 2009): Comment created by romanb: Can we see the classes and their mappings? AbstractUser, User, Setting and TopnewsSetting. Then I can set up a test to reproduce it. Thanks!
Author
Owner

@doctrinebot commented on GitHub (Dec 2, 2009):

Comment created by nicokaiser:

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

@doctrinebot commented on GitHub (Dec 2, 2009): Comment created by nicokaiser: Oh no I forgot to change TopnewsSetting to Setting in this report, there is no inheritance, just copy & paste bug.
Author
Owner

@doctrinebot commented on GitHub (Dec 3, 2009):

Comment created by nicokaiser:

Here are the classes and example code:

http://pastie.org/private/ljkiowarvm9trhdyug903q

@doctrinebot commented on GitHub (Dec 3, 2009): Comment created by nicokaiser: Here are the classes and example code: http://pastie.org/private/ljkiowarvm9trhdyug903q
Author
Owner

@doctrinebot commented on GitHub (Dec 3, 2009):

Comment created by romanb:

Successfully reproduced in our test suite and working on it.

@doctrinebot commented on GitHub (Dec 3, 2009): Comment created by romanb: Successfully reproduced in our test suite and working on it.
Author
Owner

@doctrinebot commented on GitHub (Dec 3, 2009):

Comment created by romanb:

Should be fixed now. Thanks for reporting.

@doctrinebot commented on GitHub (Dec 3, 2009): Comment created by romanb: Should be fixed now. Thanks for reporting.
Author
Owner

@doctrinebot commented on GitHub (Dec 3, 2009):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Dec 3, 2009): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#230