title: One to many relationship in MyBatis
body: <p>I'm trying to use MyBatis to map a one to many relationship in my data model. This is based on the following classes: </p>
  
  <pre><code>class Team{
      String mId;
      String mName;
      List&lt;Player&gt; mPlayers;
  }
  
  class Player{
      String mId;
      String mName;
  }
  </code></pre>
  
  <p>I would like to write a query that returns a list of matches, each populated with the tags that correspond to that match. </p>
  
  <pre><code>&lt;select id="getTeams" resultType="Team" resultMap="TeamMap"&gt;
      SELECT id, name, players.id as player_id, players.name as player_name
      FROM teams
      JOIN players ON teams.id = players.team_id
  &lt;/select&gt;
  
  
  &lt;resultMap type="Team" id="TeamMap"&gt;
      &lt;id property="mId" column="id"/&gt;
      &lt;result property="mName" column="name"/&gt;
  
      &lt;collection property="mTags" javaType="List" ofType="Player"&gt;
          &lt;id property="player_id" column="mId"/&gt;
          &lt;result property="player_name" column="mName"/&gt;
      &lt;/collection&gt;
  
  &lt;/resultMap&gt;
  </code></pre>
  
  <p>But the problem I'm having with this is that each Team object is only populated with a single Player. How can I change this to ensure that each team contains all players that belong to it?</p>