diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 9f1a269b2..2cd6895dc 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -1012,12 +1012,16 @@ class SqlWalker implements TreeWalker $identificationVarDecls = $subselectFromClause->identificationVariableDeclarations; $firstIdentificationVarDecl = $identificationVarDecls[0]; $rangeDecl = $firstIdentificationVarDecl->rangeVariableDeclaration; - $class = $this->_em->getClassMetadata($rangeDecl->abstractSchemaName); $dqlAlias = $rangeDecl->aliasIdentificationVariable; + $class = $this->_em->getClassMetadata($rangeDecl->abstractSchemaName); $sql = ' FROM ' . $class->getQuotedTableName($this->_platform) . ' ' . $this->getSqlTableAlias($class->primaryTable['name'], $dqlAlias); + if ($class->isInheritanceTypeJoined()) { + $sql .= $this->_generateClassTableInheritanceJoins($class, $dqlAlias); + } + foreach ($firstIdentificationVarDecl->joinVariableDeclarations as $joinVarDecl) { $sql .= $this->walkJoinVariableDeclaration($joinVarDecl); }