title: How to Iterate through HashMap in MyBatis foreach?
body: <p>I'm trying to produce a sql which is as below in mybatis.</p>
  
  <pre><code>SELECT COL_C
  FROM TBLE_1
  WHERE (COL_A, COL_B) in ( ('kp','kar'),('srt','sach'));
  </code></pre>
  
  <p>And my input parameter type is HashMap. Now How do I generate SQL from mapper xml file. The below code throws exception saying map evaluated to null.</p>
  
  <pre><code>&lt;select id="selectCOLC" parameterType="java.util.HashMap" resultType="String"&gt;
      SELECT COL_C
      FROM TBLE_1
      WHERE (COL_A, COL_B) in 
      &lt;foreach item="item" collection="#{map.keySet()}" open="((" separator="),(" close="))"&gt;
          #{item},#{item.get(item)}
      &lt;/foreach&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>One of the other approach is to create a class with key value fields, create a list of object and then pass the <code>parameterType</code> as <code>list</code> which would look like following.</p>
  
  <pre><code>&lt;select id="selectCOLC" parameterType="list" resultType="String"&gt;
          SELECT COL_C
          FROM TBLE_1
          WHERE (COL_A, COL_B) in 
          &lt;foreach item="item" collection="list" open="((" separator="),(" close="))"&gt;
              #{item.getKey()},#{item.getVal()}
          &lt;/foreach&gt;
      &lt;/select&gt;
  </code></pre>
  
  <p>But is there any way to my mapper work for the first approach? other than changing the query to union</p>