Java Oracle Ibatis 批量 Insert 出错(SQL执行出错???)!!!!

Java,map部分

    String insertCompId = "123,234";
    String ttId = "123,234";
        String ticketCode = "abc";

    String[] insertCompIdaa = insertCompId.split(",");
        String[] ttidaa = ttId.split(",");

    Map map = new HashMap();

            List<String> ttIdList = new ArrayList<String>();
            List<String> insertCompIdList = new ArrayList<String>();

            for (int i = 0; i < ttidaa.length; i++) {
                for (int j = 0; j < insertCompIdaa.length; j++) {
                    ttIdList.add(ttidaa[i]);
                    insertCompIdList.add(insertCompIdaa[j]);
                }
            }
            map.put("tickettypeid", ttIdList);
            map.put("ticketcodetype", ticketCode);
            map.put("insertcompid", insertCompIdList);

在上面拿到map后,传到执行SQL的部分

SQL部分

 <insert id="testInsertTicketCodeRelation" parameterClass="java.util.Map" >
        INSERT ALL
        <iterate>
        INTO TICKET_TYPE_TICKET_CODE
            (
            TICKET_TYPE_TICKET_CODE_ID,
            TICKET_TYPE_ID,
            TICKET_CODE_TYPE,
            COMPONENT_ID
            )
            VALUES
            (
            TICKET_TYPE_AND_CODE_ID_SEQ.nextVal,
            #tickettypeid[]#,
            #ticketcodetype#,
            #insertcompid[]#
            )
        </iterate>
        SELECT 1 FROM DUAL
    </insert>

下面是报错

 java.sql.SQLException: Insert statements cannot be executed as a query.
    at com.ibatis.sqlmap.engine.mapping.statement.InsertStatement.executeQueryForObject(InsertStatement.java:35)
    at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:518)
    at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:493)
    at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:106)
    at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:82)
    at com.hkt.engineering.oneoss.ticketing.dao.tickettype.impl.TicketTypeTicketCodeDAO.testInsertTicketCodeRelation(TicketTypeTicketCodeDAO.java:280)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    ........(剩下部分省略)

错误有点长,请各位帮忙看看,这个错误怎么产生的,要怎么解决,谢谢!!!

2个回答

你多了 SELECT 1 FROM DUAL

qq_24534807
qq_24534807 与这个没关吧,去掉了,还是出错诶,还是一样错误
大约 3 年之前 回复

多了个ALL吧??insert into...

qq_24534807
qq_24534807 不是这个
大约 3 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐