MyBatis , too many parameters provided in the RPC request.The maximum is 2100
<p>So I am trying to do a batch insert using MyBatis below is my xml mapper</p>

<pre><code>&lt;insert id="insertMessages" parameterType="java.util.List"&gt;
    INSERT INTO Messages(user, id, month,
    key, value, name,
    message, dateCreated, createdBy)
    VALUES
    &lt;foreach item="item"  collection="list" open="(" separator="),("  close=")"&gt;
                #{item.user},
                #{item.id},
                #{item.month},
                #{item.key},
                #{item.value},
                #{item.name},
                #{item.message},
                GETDATE(),
                #{item.createdBy}
    &lt;/foreach&gt;

&lt;/insert&gt;
</code></pre>

<p>right now it only works when the batch size is 200 or less. Anything more than 200, gets the error : </p>

<p>-The incoming tabular data stream(TDS) remote procedure call (RPC) protocol stream is incorrect.Too many parameters provided in the RPC request.The maximum is 2100</p>

<p>which is caused by SQL server not being able to take more than 2100 paramerters and myBatis builds query with "?" and then passes parameters to the query. In my case it is 8 parameters so if batch is 300 then 2400 parameters will be passed to DB. So I can keep adjusting the batch insert size for inserts but there's probably a better way. What can I do to not hit this parameters limitation on SQL server side? without changing SQL server. Thanks!</p>