title: Join map and refer to its key/value in HQL
body: <p>Suppose I have a map:</p>
  
  <pre class="lang-xml prettyprint-override"><code>        &lt;map name="externalIds" table="album_external_ids"&gt;
              &lt;key column="album_id" not-null="true"/&gt;
              &lt;map-key-many-to-many class="Major" column="major_id"/&gt;
              &lt;element column="external_id" type="string" not-null="true"/&gt;
          &lt;/map&gt; 
  </code></pre>
  
  <p>How do I make a HQL meaning "select entities where map key's id == :foo and map value == :bar"?</p>
  
  <p>I can join it using <code>select album from Album album join album.externalIds ids</code>
  But how would I then refer to ids' key and value?
  ids.key.id = :foo and ids.value = :bar doesn't work, and hibernate doc is silent on this topic.</p>
  
  <p>Naive approaches that didn't work:</p>
  
  <pre class="lang-sql prettyprint-override"><code>select album 
  from Album album 
  join album.externalIds externalId
      where index(externalId).id = :foo and externalId = :bar
  </code></pre>
  
  <p>and</p>
  
  <pre class="lang-sql prettyprint-override"><code>select album 
  from Album album 
  join album.externalIds externalId 
  join index(externalId) major
      where major.id = :foo and externalId = :bar
  </code></pre>