Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-3122

Querying entities with ResolveTargetEntity

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.4.2
    • Fix Version/s: None
    • Component/s: None
    • Security Level: All
    • Labels:
      None

      Description

      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:

      An exception occurred while executing 'SELECT t1.id AS id2 FROM bclass_table_name t1 WHERE t0.id = ?' with params [1]:

      SQLSTATE[42S22]: Column not found: 1054 Unknown column 't0.id' in 'where clause'

      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

        Activity

        Hide
        Marco Pivetta added a comment -

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

        Show
        Marco Pivetta added a comment - Is AClass a mapped superclass or the root of the inheritance?
        Hide
        Heo added a comment -

        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.

        Show
        Heo added a comment - 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.
        Hide
        Marco Pivetta added a comment -

        Heo can you abstract a test case for this?

        Show
        Marco Pivetta added a comment - Heo can you abstract a test case for this?

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Heo
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: