title: mybatis 3 selectkey inside foreach
body: <p>MyBatis 3  - Spring</p>
  
  <p>I want to insert list of items and for every item id has to generate from "TVA_UPSELLADMIN_CHANNEL_SEQ.nextVal" but i am getting .xml validation error that you can't sub-child "selectKey" inside "foreach".</p>
  
  <pre><code>&lt;insert id="insertServiceMappings" parameterType="java.util.List"&gt;
  
  INSERT  
  &lt;foreach collection="list" item="channel" index="index" &gt;
  
  &lt;selectKey keyProperty="id" resultType="long" order="BEFORE"&gt;
              SELECT TVA_UPSELLADMIN_CHANNEL_SEQ.nextVal from dual
          &lt;/selectKey&gt;
  
  into tva_upselladmin_channel (id,source_id, service_id, name) values (#{id}, #{channel.sourceId}, #{channel.serviceId}, #{channel.name})
  &lt;/foreach&gt;
  &lt;/insert&gt;
  </code></pre>