Mybatis-3: Can't use List<String[]> on foreach

Created on 12 Aug 2017  路  2Comments  路  Source: mybatis/mybatis-3

I try to insert List

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.patentquery.dao.impl.MyDaoImpl">
    <sql id="table_name">patentquery</sql>
    <sql id="column_all">fan,xpn,ifpct,ti,ab,aarea,ifgd,parea,icm,cypt,tecd,tecdid1,tecdid2,tecdid3,effect,pd,apd,pay,py</sql>
    <insert id="batchInsert" parameterType="java.util.List">
        INSERT INTO <include refid="table_name"/>
        (fan,xpn)
        VALUES
        <foreach collection="list" item="tag" separator="," index="index">
            (
              #{tag[0]},#{tag[1]}
            )
        </foreach>
    </insert>
</mapper>

So, it's that mybatis unsupport the insert the type of List Because I found that all data insert into the database is the same,is the second last row data.
I try to read the source code,and found that org.apache.ibatis.scripting.defaults.DefaultParameterHandler.class
is try to deal with this problem,but it seems that it didn't work in my computer.Can anybody help me?

Related Issues

  • #966

Most helpful comment

@wudeyong Thanks you for your reporting!

Probably, a cause is here in the ForEachSqlNode. I will try to fix this issue.

All 2 comments

@wudeyong Thanks you for your reporting!

Probably, a cause is here in the ForEachSqlNode. I will try to fix this issue.

We will consider fix in 3.4.6 or later because modification other than ForEachSqlNode is also necessary

Was this page helpful?
0 / 5 - 0 ratings