<insert id="insertServiceMappings" parameterType="java.util.List" useGeneratedKeys="true">
<selectKey keyProperty="id" resultType="java.lang.Long" order="BEFORE">
SELECT TVA_UPSELLADMIN_CHANNEL_SEQ.nextVal as id FROM DUAL
</selectKey>
INSERT INTO
tva_upselladmin_channel (id,source_id, service_id, name)
SELECT TVA_UPSELLADMIN_CHANNEL_SEQ.nextVal, A.* from (
<foreach collection="list" item="channel" index="index" separator="union all">
SELECT
#{channel.sourceId} as source_id,
#{channel.serviceId} as service_id,
#{channel.name}) as name
FROM DUAL
</foreach> ) A
</insert>
参考:https://stackoverflow.com/questions/31748177/mybatis-3-selectkey-inside-foreach