Skip to content


DDC-1454: SQL error when requesting state for unknown joined inheritance entity with natural identifier #2082

doctrinebot opened this Issue · 5 comments

2 participants


Jira issue originally created by user gedrox:

When having unknown (not cached by UnitOfWork) joined inheritance entity with natural identifier (GENERATORTYPENONE), method UnitOfWork::getEntityState() fails with SQL error:

Column not found: 1054 Unknown column 't1.file_id' in 'where clause'

Will attach testcase right after creating the issue.


Comment created by gedrox:

Test case.


Comment created by gedrox:

Possible change diff for file Doctrine/ORM/Persisters/BasicEntityPersister.php from Doctrine ORM 2.1.2.

Idea is to use the main table (not inherited one) if the column is a part of ID. So, I guess, it will be in both tables.

@@ -1197,7 <ins>1197,7 @@ class BasicEntityPersister
             $conditionSql .= $conditionSql ? ' AND ' : '';

             if (isset($this->_class->columnNames[$field])) {
-                if (isset($this->_class->fieldMappings[$field]['inherited'])) {
</ins>                if (isset($this->*class->fieldMappings[$field]['inherited']) && empty($this->*class->fieldMappings[$field]['id'])) {
                     $conditionSql .= $this->*getSQLTableAlias($this->*class->fieldMappings[$field]['inherited']) . '.';
                 } else {
                     $conditionSql .= $this->*getSQLTableAlias($this->*class->name) . '.';

Comment created by @beberlei:



Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.1.3 milestone
@doctrinebot doctrinebot closed this
@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.