title: doctrine fetch join query on three tables
body: <p>I have three entities in my Symfony2 project:</p>
  
  <ul>
  <li>User</li>
  <li>Group</li>
  <li>Organisation</li>
  </ul>
  
  <p>The fourth entity represents relation between three above:</p>
  
  <ul>
  <li>UserOrganisationGroup {userId, organisationId, groupId}</li>
  </ul>
  
  <p>Now, I need fetch join query that somehow will load User and its Groups and Organisations. I though of something like:</p>
  
  <pre><code>SELECT u, g, o, uog 
  FROM Yocto\Bundle\UserBundle\Entity\User u 
  JOIN u.userOrganisationGroup uog
  JOIN uog.organisation o
  JOIN uog.group g
  WHERE uog.user = 1
  </code></pre>
  
  <p>But all I get is User Entity, and Organisation and Group seems to be NULL. What am I doing wrong? I know for the fact that database has records as follows:</p>
  
  <pre><code>User
  id | 1
  
  Organisation
  id | 1
  
  Group
  id | 1
  
  UserOrganisationGroup
  userId         |  1
  groupId        |  1
  organisationId |  1
  
  
  
  array(1) {
    [0]=&gt;
    object(stdClass)#490 (15) {
      ["__CLASS__"]=&gt;
      string(35) "UserBundle\Entity\User"
      ["id"]=&gt;
      int(1)
      ["userOrganisationGroup"]=&gt;
      array(1) {
        [0]=&gt;
        object(stdClass)#502 (4) {
          ["__CLASS__"]=&gt;
          string(52) "UserBundle\Entity\UserOrganisationGroup"
          ["user"]=&gt;
          object(stdClass)#507 (15) {
            ["__CLASS__"]=&gt;
            string(35) "UserBundle\Entity\User"
            ["id"]=&gt;
            int(1)
            ["userOrganisationGroup"]=&gt;
            array(1) {
              [0]=&gt;
              object(stdClass)#525 (4) {
                ["__CLASS__"]=&gt;
                string(52) "UserBundle\Entity\UserOrganisationGroup"
                ["user"]=&gt;
                string(35) "UserBundle\Entity\User"
                ["group"]=&gt;
                NULL
                ["organisation"]=&gt;
                NULL
              }
            }
          }
          ["group"]=&gt;
          NULL
          ["organisation"]=&gt;
          NULL
        }
      }
    }
  }
  </code></pre>