DDC-3122: Querying entities with ResolveTargetEntity #3900

Open
doctrinebot opened this Issue May 14, 2014 · 3 comments

2 participants

@doctrinebot

Jira issue originally created by user heo:

Hello

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:

array(
  '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 t1.id AS id2 FROM bclasstablename t1 WHERE t0.id = ?' with params [1]:{quote}

{quote}SQLSTATE[42S22]: Column not found: 1054 Unknown column 't0.id' 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:

http://stackoverflow.com/questions/17588682/doctrine-inheritance-replacement

@doctrinebot

Comment created by @ocramius:

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

@doctrinebot

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.

@doctrinebot

Comment created by @ocramius:

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

@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment