Returning HashMap of results in MyBatis (rather than List)
<p>Can MyBatis return a HashMap of results, instead of a List?
e.g. given a table:</p>

<pre><code>foo  | bar
 1   |  a
 2   |  b
</code></pre>

<p>and a query </p>

<pre><code>SELECT foo, bar FROM foobar
</code></pre>

<p>Return a result of <code>HashMap&lt;String, String&gt; map</code> where <code>map.get(1) == 'a'</code>, <code>map.get(2) == 'b'</code> etc?</p>

<p>I've tried variations on the following:</p>

<pre><code>    &lt;resultMap id="hashMapResult" type="java.util.HashMap"&gt;
       &lt;id  column="foo"  /&gt;
       &lt;result property="bar" column="bar"/&gt;
    &lt;/resultMap&gt;

    &lt;select id="personStatuses" resultMap="hashMapResult"&gt;
      SELECT foo, bar FROM foobar
    &lt;/select&gt;
</code></pre>

<p>But just get the error: <code>Expected one result (or null) to be returned by selectOne(), but found: ...</code></p>

<p>Where tables have primary keys, it would be more useful to be able to get the results as a Map of PK => row, than just a List of rows.</p>