我试图在数据库中插入一个列表,但我有一些错误:org.springframework.jdbc.BadSqlGrammarException:SqlSession操作; 糟糕的SQL语法[]; 嵌套异常是java.sql.SQLException:ORA-00913:值太多(...).
我用过的代码:
<insert id="insertListMyObject" parameterType="java.util.List" >
INSERT INTO my_table
(ID_ITEM,
ATT1,
ATT2)
VALUES
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
#{item.idItem, jdbcType=BIGINT},
#{item.att1, jdbcType=INTEGER},
#{item.att2, jdbcType=STRING}
</foreach>
</insert>
Run Code Online (Sandbox Code Playgroud)
我的道歉方法:
SqlSessionTemplate().insert(MAPPER+".insertListMyObject", parameterList);
Run Code Online (Sandbox Code Playgroud)
parameterList的位置是:
List<MyObjects>.
Run Code Online (Sandbox Code Playgroud)
有人知道这个错误是什么?或者,如果确实存在多个插入操作的更好方法.
非常感谢!