title: How do I get a Map<String, Integer> from MyBatis? Cause: java.sql.SQLException: Invalid value for getInt() - 'NONE'
body: <p>I tried to follow <a href="https://stackoverflow.com/questions/11913013/return-hashmap-in-mybatis-and-use-it-as-modelattribute-in-spring-mvc">Return HashMap in mybatis and use it as ModelAttribute in spring MVC</a> (Option 1) and <a href="https://stackoverflow.com/questions/36400538/mybatis-resultmap-is-hashmapstring-object">Mybatis ResultMap is HashMap&lt;String,Object&gt;</a>. I have</p>
  
  <pre><code>@Select("select sources.host as 'key', count(*) total ... group by host")
  @MapKey("key")
  Map&lt;String, Integer&gt; getSourcesById(@Param("id")String id, @Param("hitDate")Date hitDate);
  </code></pre>
  
  <p>It returns an error</p>
  
  <blockquote>
    <p>Error attempting to get column 'key' from result set.  Cause: java.sql.SQLException: Invalid value for getInt() - 'NONE'
        ; SQL []; Invalid value for getInt() - 'NONE'; nested exception is java.sql.SQLException: Invalid value for getInt() - 'NONE'</p>
  </blockquote>
  
  <p>The query works fine in MySQL and returns</p>
  
  <pre><code>| key         | total |
  +-------------+-------+
  | NONE        |    33 |
  | twitter.com |     1 |
  </code></pre>
  
  <p>It's as if it is not using the <code>@MapKey</code> annotation.</p>
  
  <hr>
  
  <p>I tried</p>
  
  <pre><code>List&lt;AbstractMap.SimpleEntry&lt;String, Integer&gt;&gt; getSourcesById(...)
  </code></pre>
  
  <p>But it gave</p>
  
  <blockquote>
    <p>nested exception is org.apache.ibatis.executor.ExecutorException: No constructor found in java.util.AbstractMap$SimpleEntry matching [java.lang.String, java.lang.Long]</p>
  </blockquote>
  
  <p>Also tried this with the same error.</p>
  
  <pre><code>List&lt;AbstractMap.SimpleEntry&lt;String, Long&gt;&gt; 
  </code></pre>
  
  <p><a href="https://docs.oracle.com/javase/7/docs/api/java/util/AbstractMap.SimpleEntry.html#constructor_summary" rel="nofollow noreferrer">https://docs.oracle.com/javase/7/docs/api/java/util/AbstractMap.SimpleEntry.html#constructor_summary</a></p>
  
  <p>MyBatis 3.4.6, MyBatis-Spring 1.3.2</p>