title: MyBatis work with dynamic queries, such as count(*) or data in a new column
body: <p>Lets assume I have user_partner_table</p>
  
  <pre><code>id, user_id, partner_id, app_completed, user_name, partner_name
  1, 2345, 232, t, sam, A&amp;C Bank
  2, 2345, 121, f, sam, M&amp;M Bank
  3, 4324, 123, t, tom, DC Bank
  4, 4324, 121, t, tom, M&amp;M Bank
  5, 1211, 134, f, harry, USBank
  6, 1211, 111, t, harry, creditunion
  </code></pre>
  
  <p>In my DAO Class I have getters and setters for id, user_id, partner_id, app_completed, user_name, partner_name</p>
  
  <p>If I want to get any of the data based on the columns that are available I can write a query and in the query make <code>resultType="UserPartnerDAO"</code> and have results as <code>ArrayList&lt;UserPartnerDAO&gt;</code>. </p>
  
  <p>But what if I want to run query which generate different data column with aggregate data. Example: </p>
  
  <p>Let say I was user_id, <code>count_of_app_completed</code> basically how many applications each user has completed, so its a <code>group by</code>. Now there is no column name <code>"count_of_app_completed"</code>
  so if I put following query in my UserPartnerMapper.xml</p>
  
  <pre><code>&lt;select id="aggregateQuery" resultType="UserPartnerDAO"&gt;
    SELECT user_id,
           COUNT(CASE WHEN completed THEN 1 END) count_of_app_completed
      FROM user_partner_table
  GROUP BY user_id
  &lt;/select&gt;
  </code></pre>
  
  <p>What how do I get access to the dynamic column?, also at the same time 
  How can I get access to all the columns? 
  Is it correct to set resultType as "<code>UserPartnerDAO</code>" or should the result type be something else? </p>