title: Doctrine DQL JOIN
body: <p>I have the following entities mapped with <a href="http://www.doctrine-project.org/projects/orm/2.1/docs/hu" rel="nofollow">Doctrine 2</a>:</p>
  
  <pre><code>class Zone
  {
      /**
       * @ManyToOne(targetEntity="Zone", inversedBy="children")
       * @var Zone
       */
      protected $parent;
  
      /**
       * @OneToMany(targetEntity="Zone", mappedBy="parent")
       * @var Zone[]
       */
      protected $children;
  
      /**
       * @ManyToMany(targetEntity="Zone")
       * @var Zone[]
       */
      protected $descendants;
  }
  
  class Restaurant
  {
      /**
       * @ManyToOne(targetEntity="Zone")
       * @var Zone
       */
      protected $zone;
  }
  </code></pre>
  
  <p>Basically, a Zone has a parent, and therefore children. Because children may have children themselves, each Zone keeps a list of all its descendants as well.</p>
  
  <p>Each Restaurant is assigned a Zone.</p>
  
  <p>What I want to do, is to perform a DQL JOIN to return all Restaurants in a specific Zone (including all of its descendants).</p>
  
  <p>If I had to do this in plain SQL, I would write:</p>
  
  <pre><code>SELECT r.* from Zone z
  JOIN ZoneDescendant d ON d.zoneId = z.id
  JOIN Restaurant r ON r.zoneId = d.descendantId
  WHERE z.id = ?;
  </code></pre>
  
  <p>Is it possible to do this with Doctrine DQL, without adding a <code>$restaurants</code> property on the Zone, and having to complexify the domain model uselessly?</p>