title: Doctrine: Is it possible to INDEX BY a related field?
body: <p>I have a Doctrine model (<code>Assignment</code>), which has a many-to-one relationship with another model (<code>Region</code>). Assignments are owned by users (with each user having only one assignment per region at a time), and I am trying to use <code>indexBy</code> to have the user's array of assignments be keyed by the ID of the assignment's region. However, I only get standard 0..n numeric keys.</p>
  
  <p>When I try to run a DQL query like <code>SELECT am, reg, user FROM Assignment am INDEX BY [...] JOIN am.region reg JOIN am.user user WHERE user.id = ?1</code>, none of these values for INDEX BY work:</p>
  
  <ul>
  <li><code>region</code> (Error: Invalid PathExpression. Must be a StateFieldPathExpression.)</li>
  <li><code>region_id</code> (Error: Class ...\Assignment has no field or association named region_id)</li>
  <li><code>region.id</code> (Error: Expected end of string, got '.')</li>
  </ul>
  
  <p>Is this possible? If not, then what would be a convenient way to access a <code>User</code>'s assignment on a region without <code>indexBy</code>?</p>