Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-3181

Class Table Inheritance - wrong table order on insert with more than one level of inheritance

    Details

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

      Description

      note: this issue seems the same as DDC-732

      When using class table inheritance with multiple levels i.e.:
      Object -> SolidObject -> Building -> House
      (House inherits from Building, Building from SolidObject, SolidObject from Object)

      Object has the discriminator column and mapping. When persisting a new House entity I get a foreign key error because there is no row in the Building table.

      I searched in the Code and found the problem. In the class "Doctrine\ORM\Persisters\JoinedSubclassPersister" in function "executeInserts()" around line 146 the array $subTableStmts is first declared and then filled with insert statements. The statement of the House-table is first added, and then the parent-tables (except the root-table "Object", since that one is executed first).

      So the order in which the insert statements are executed is:
      1 Insert into Object ...
      2 Insert into House ... (which causes the error)
      3 insert into Building ...
      4 Insert into SolidObject

      I edited the source to insert into the parent-tables (first SolidObject, then Building) before inserting into the table that belongs to the class that is persisted (House). And this works

        Activity

        Hide
        mohammed added a comment -

        hello, can you please send me the modified lines or just share with me the whole method executeInserts.
        thanks in advance

        Show
        mohammed added a comment - hello, can you please send me the modified lines or just share with me the whole method executeInserts. thanks in advance

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            M. de Lange
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: