Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use List<String[]> on foreach #1074

Open
wudeyong opened this issue Aug 12, 2017 · 2 comments
Open

Can't use List<String[]> on foreach #1074

wudeyong opened this issue Aug 12, 2017 · 2 comments
Assignees

Comments

@wudeyong
Copy link

wudeyong commented Aug 12, 2017

I try to insert List<String []> by using xml mapper file.Unfortunately, i got a wrong reslut,here is my xml file.

<?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<String[]>? 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

@kazuki43zoo
Copy link
Member

kazuki43zoo commented Aug 13, 2017

@wudeyong Thanks you for your reporting!

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

kazuki43zoo added a commit to kazuki43zoo/mybatis-3 that referenced this issue Aug 13, 2017
@kazuki43zoo kazuki43zoo self-assigned this Aug 13, 2017
@kazuki43zoo kazuki43zoo changed the title Why can't insert the List<String []> type? Can't use List<String[]> on foreach Aug 13, 2017
@kazuki43zoo
Copy link
Member

kazuki43zoo commented Aug 15, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants