title: Join multiple Tables including 2 join Tables
body: <p>i try to join multiple Tables in one Query.</p>
  
  <p>My Entitie Relations:</p>
  
  <p>Person</p>
  
  <pre><code>Entities\Person:
    type: entity
    table: person
    manyToOne:
      address:
        targetEntity: Address
        joinColumn:
          name: idaddress
          referencedColumnName: idaddress
    manyToMany:
      tags:
        targetEntity: Tag
        joinTable:
          name: persons_tags
          joinColumns:
            person_idperson:
              referencedColumnName: idperson
          inverseJoinColumns:
            tag_idtag:
              referencedColumnName: idtag
  </code></pre>
  
  <p>Tag</p>
  
  <pre><code>Entities\Tag:
    type: entity
    table: tag
    manyToMany:
      sms:
        targetEntity: Sms
        mappedBy: tag
  </code></pre>
  
  <p>sms</p>
  
  <pre><code>  manyToMany:
      tag:
        targetEntity: Tag
        joinTable:
          name: sms_tags
          joinColumns:
            sms_idsms:
              referencedColumnName: idsms
          inverseJoinColumns:
            tag_idtag:
              referencedColumnName: idtag
  </code></pre>
  
  <p>This is a valid working SQL Statement:</p>
  
  <pre><code>SELECT DISTINCT person.lastname, person.firstname, address.mobileprivate, address.mobilebusiness FROM
      `address`,
      `person`,
      `persons_tags`,
      `sms_tags`
  WHERE
      person.idaddress = address.idaddress
      AND person.idperson = persons_tags.person_idperson
      AND persons_tags.tag_idtag = sms_tags.tag_idtag
      AND sms_tags.sms_idsms = (myINPUT)
  </code></pre>
  
  <p>Now i try to join the needed Entities in DQL to get the same result:</p>
  
  <pre><code>SELECT DISTINCT s, t, p, a 
  FROM Entities\Sms s 
  JOIN s.sms_idsms t 
  JOIN t.person_idperson p 
  JOIN p.idaddress a 
  WHERE s.idsms = (myINPUT)
  </code></pre>
  
  <p>But i only get an error:</p>
  
  <pre><code>PHP Fatal error:  Uncaught exception 'Doctrine\\ORM\\Query\\QueryException' with message '
  SELECT DISTINCT s, t, p, a 
  FROM Entities\\Sms s 
  JOIN s.sms_idsms t 
  JOIN t.person_idperson p 
  JOIN p.idaddress a 
  WHERE s.idsms = 2' in 
  /var/www/ci_doc_rem/Codeigniter_Doctrine/source/application/libraries/Doctrine/ORM/Query/QueryException.php:39
  Stack trace:
  #0 /var/www/ci_doc_rem/Codeigniter_Doctrine/source/application/libraries/Doctrine/ORM/Query/Parser.php(429): Doctrine\\ORM\\Query\\QueryException::dqlError('SELECT DISTINCT...')
  #1 /var/www/ci_doc_rem/Codeigniter_Doctrine/source/application/libraries/Doctrine/ORM/Query/Parser.php(925): Doctrine\\ORM\\Query\\Parser-&gt;semanticalError('Class Entities\\...')
  #2 /var/www/ci_doc_rem/Codeigniter_Doctrine/source/application/libraries/Doctrine/ORM/Query/Parser.php(1561): Doctrine\\ORM\\Query\\Parser-&gt;JoinAssociationPathExpression()
  #3 /var/www/ci_doc_rem/Codeigniter_Doctrine/source/application/libraries/Doctrine/ORM/Query/Parser.php(1506): Doctrine\\ORM\\Query\\Parser-&gt;JoinAssociationDeclaration()
  #4 /var/www/ci_ in /var/www/ci_doc_rem/Codeigniter_Doctrine/source/application/libraries/Doctrine/ORM/Query/QueryException.php on line 49
  </code></pre>
  
  <p>How to write a DQL Query like the working SQL Query?</p>
  
  <p>I try to avoid a native SQL Query</p>
  
  <p>Here is a try with the Query Builder:</p>
  
  <pre><code>    $qb-&gt;select(array('s', 't', 'p', 'a'))
         -&gt;from('Entities\Sms', 's')
         -&gt;leftJoin('s.tag', 't')
         -&gt;leftJoin('t.person', 'p')
         -&gt;leftJoin('p.address', 'a')
         -&gt;where('s.idsms = 1');
  </code></pre>
  
  <p>And the Error Message</p>
  
  <pre><code>PHP Fatal error:  Uncaught exception 'Doctrine\\ORM\\Query\\QueryException' with message 'SELECT s, t, p, a FROM Entities\\Sms s LEFT JOIN s.tag t LEFT JOIN t.person p LEFT JOIN p.address a WHERE s.idsms = 1' in /var/www/ci_doc_rem/Codeigniter_Doctrine/source/application/libraries/Doctrine/ORM/Query/QueryException.php:39\nStack trace:\n#0 /var/www/ci_doc_rem/Codeigniter_Doctrine/source/application/libraries/Doctrine/ORM/Query/Parser.php(429): Doctrine\\ORM\\Query\\QueryException::dqlError('SELECT s, t, p,...')\n#1 /var/www/ci_doc_rem/Codeigniter_Doctrine/source/application/libraries/Doctrine/ORM/Query/Parser.php(925): Doctrine\\ORM\\Query\\Parser-&gt;semanticalError('Class Entities\\...')\n#2 /var/www/ci_doc_rem/Codeigniter_Doctrine/source/application/libraries/Doctrine/ORM/Query/Parser.php(1561): Doctrine\\ORM\\Query\\Parser-&gt;JoinAssociationPathExpression()\n#3 /var/www/ci_doc_rem/Codeigniter_Doctrine/source/application/libraries/Doctrine/ORM/Query/Parser.php(1506): Doctrine\\ORM\\Query\\Parser-&gt;JoinAssociationDeclaration()\n#4 /var/www/ci_doc_rem/Cod in /var/www/ci_doc_rem/Codeigniter_Doctrine/source/application/libraries/Doctrine/ORM/Query/QueryException.php on line 49
  </code></pre>