title: MyBatis doesn't return all the results from the query
body: <h1>The Problem</h1>
  
  <p>I have a query that returns 17 records.  When I use MyBatis with a map that has an <code>&lt;association&gt;</code> it returns 6 records. <em>Note that this doesn't happen with my other maps, I have many other maps with associations that all work fine.</em></p>
  
  <p><strong>Query:</strong></p>
  
  <pre><code>    with leave_counts as 
      (
          select leave_type_id, count(llm.leave_id) as count
          from lw_leave_master llm
          group by leave_type_id
      )
      select llt.leave_type_id, llt.leave_type_abbr_tx, 
              llt.leave_type_desc_tx, lc.count as count_nm
      from lw_leave_type llt
          join leave_counts lc on lc.leave_type_id=llt.leave_type_id
      order by llt.leave_type_abbr_tx
  </code></pre>
  
  <p><strong>Map:</strong></p>
  
  <pre><code>&lt;resultMap id="typeCountMap" type="mypackage.myclass"&gt;
      &lt;result property="count" column="count_nm"/&gt;
      &lt;association property="type" resultMap="package.myMap"/&gt;
  &lt;/resultMap&gt;
  
  
  &lt;resultMap id="myMap" type="mypackage.myclass2"&gt;
      &lt;result property="id" column="leave_type_id"/&gt;
      &lt;result property="abbr" column="leave_type_abbr_tx"/&gt;
      &lt;result property="description" column="leave_type_desc_tx"/&gt;
  &lt;/resultMap&gt;
  </code></pre>
  
  <p>The <code>&lt;association&gt;</code> in <code>typeCountMap</code> refers to the map <code>myMap</code>.</p>
  
  <p>This returns 6 records every time.  Grabbing the actual query run from the logger and running it manually returns 17 records.</p>
  
  <h1>Solutions?</h1>
  
  <p><strong>There are two things I can do to get MyBatis to return all 17 records</strong></p>
  
  <p><strong>#1</strong></p>
  
  <p>If I remove the <code>lc.count as count_nm</code> from my query I get all 17 records returned (just with no values associated with them)</p>
  
  <pre><code>    with leave_counts as 
      (
          select leave_type_id, count(llm.leave_id) as count
          from lw_leave_master llm
          group by leave_type_id
      )
      select llt.leave_type_id, llt.leave_type_abbr_tx, 
              llt.leave_type_desc_tx
      from lw_leave_type llt
          join leave_counts lc on lc.leave_type_id=llt.leave_type_id
      order by llt.leave_type_abbr_tx
  </code></pre>
  
  <p>This is obviously not a good solution, but I wanted to include this in case it would help you figure out what I'm doing wrong.</p>
  
  <p><strong>#2</strong></p>
  
  <p>If I replace the association with the contents of the other map everything works as expected.</p>
  
  <pre><code>&lt;resultMap id="typeCountMap" type="mypackage.myclass1"&gt;
      &lt;result property="count" column="count_nm"/&gt;        
      &lt;result property="type.id" column="leave_type_id"/&gt;
      &lt;result property="type.abbr" column="leave_type_abbr_tx"/&gt;
      &lt;result property="type.description" column="leave_type_desc_tx"/&gt;
  &lt;/resultMap&gt;
  </code></pre>
  
  <p>This obviously is what I'll do if I don't find another solution, since this does work.  It would just be nice to use the <code>&lt;association&gt;</code> like I have in other maps.</p>
  
  <p>I should note that I am using MyBatis 3.1.1</p>