我正在尝试向Mybatis插入一个列表并收到以下错误:
org.apache.ibatis.binding.BindingException: Parameter '__frch_e_0' not found. Available parameters are [list]
你能告诉我我失踪了吗?感谢
DAO界面:
void saveErrorMessageList(List<ErrorMessage> emList);
XML:
<insert id="saveErrorMessageList" parameterType="java.util.List">
{call
declare
ID PLS_INTEGER;
begin
<foreach collection="list" item="e" index="index" >
SELECT SEQ_ERR_ID.NEXTVAL into ID FROM DUAL;
INSERT INTO ERR (ERR_ID, CREAT_TS,
MSG_CD, MSG_TXT) values (ID,CURRENT_TIMESTAMP,
#{e.code}, #{e.message});
</foreach>
end
}
</insert>
错误讯息:
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter '__frch_e_0' not found. Available parameters are [list]
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371)
at com.sun.proxy.$Proxy11.insert(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:240)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:51)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
at com.sun.proxy.$Proxy12.saveBeneErrorMessageList(Unknown Source)
at ...
... 35 more
答案 0 :(得分:1)
检查sql
尝试更新mybatis版本。当我使用3.3.0有这个错误,但使用3.4.1它是好的
答案 1 :(得分:0)
请检查foreach标签的集合属性。我觉得价值应该是&#34; emList&#34;或在接口方法中添加@Param(org.apache.ibatis.annotations.Param)。
<foreach collection="emList" item="e" index="index" >
INSERT INTO ERR (ERR_ID, CREAT_TS,
MSG_CD, MSG_TXT) values (CURRENT_TIMESTAMP,
#{e.code}, #{e.message});
</foreach>
</insert>