title: MyBatis - Returning a HashMap
body: <p>I want the returned result of the select statement below to be <code>Map&lt;String, Profile&gt;:</code></p>
  
  <pre><code>&lt;select id="getLatestProfiles" parameterType="string" resultMap="descProfileMap"&gt;
      select ml.layerdescription, p1.* 
      from ( select max(profile_id) as profile_id
          from SyncProfiles
          group by map_layer_id) p2
      inner join SyncProfiles p1 on p1.profile_id = p2.profile_id
      inner join maplayers ml on ml.LAYERID = p1.MAP_LAYER_ID
      where ml.maxsite = #{site} 
  &lt;/select&gt;
  </code></pre>
  
  <p>I have seen this <a href="http://amolchoudhariblog.blogspot.com/2012/02/mybatis-map-select-result-to.html" rel="nofollow">post</a> which maps a String to a custom class, but the key was part of the custom class.  In my query above, the layerdescription field is not part of the Profile class since I'm aiming to have the Profile class strictly represent the syncprofiles table and the layerdescription field is in another table.</p>
  
  <p>My interface looks like:</p>
  
  <pre><code>public Map&lt;String, Profile&gt; getLatestProfiles(final String site);
  </code></pre>
  
  <p>How should descProfileMap be defined?  I want to do something like:</p>
  
  <pre><code>&lt;resultMap id="descProfileMap" type="java.util.HashMap"&gt;
      &lt;id property="key" column="layerdescription" /&gt;
      &lt;result property="value" javaType="Profile"/&gt;
  &lt;/resultMap&gt;
  </code></pre>
  
  <p>But this is clearly wrong.  Thanks for your help!</p>