3

我正在尝试向 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
4

2 回答 2

1
  • 检查sql中的列名和bean字段名

  • 尝试更新mybatis版本。当我使用 3.3.0 时出现此错误,但使用 3.4.1 就可以了

于 2016-08-17T12:25:08.887 回答
0

请检查 foreach 标签的集合属性。我觉得值应该是“emList”或在接口方法中添加@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>
于 2015-12-21T11:35:29.180 回答