Skip to content


DDC-3122: Querying entities with ResolveTargetEntity #3900

doctrinebot opened this Issue · 3 comments

2 participants


Jira issue originally created by user heo:


The problem refers to a following situation:
You have 2 classes that use a quite simple inheritance and an interface:

interface CInterface { /** ... **/ }
class AClass implements CInterface { /** ... **/ }
class BClass extends class AClass { /** ... **/ }

When we configure the ResolveTargetEntityListener the following way:

  'CInterface' => 'BClass'

when using the entity manager to find an entity:

$entityManager->find('BClass', $id);

we'll get a following Doctrine\DBAL\DBALException:
{quote}An exception occurred while executing 'SELECT AS id2 FROM bclasstablename t1 WHERE = ?' with params [1]:{quote}

{quote}SQLSTATE[42S22]: Column not found: 1054 Unknown column '' in 'where clause'{quote}

As you can see the column names are generated properly but the WHERE clause has an invalid refference to t0 table (should be t1).

Similar problem:


Comment created by @ocramius:

Is AClass a mapped superclass or the root of the inheritance?


Comment created by heo:

AClass is the root of the inheritance. I would like to add that the only problem is the "find" method. Database relations are created properly (with the SchemaTool), all keys refer to proper columns.


Comment created by @ocramius:

[~heo] can you abstract a test case for this?

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.