3

I'm trying to insert a list to Mybatis and getting the foloowing error:

org.apache.ibatis.binding.BindingException: Parameter '__frch_e_0' not found. Available parameters are [list]

Can you please let know what I'm missing. Thanks

DAO interface:

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>

Error Message:

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
Harry
  • 546
  • 6
  • 22
  • 50

2 Answers2

1
  • check column name and bean field name in sql

  • try to update mybatis version. when i use 3.3.0 have this error, but use 3.4.1 it is ok

Yifan
  • 1,185
  • 12
  • 18
  • Sorry for the late response...but upgrading the version to 3.4.2 fixed the issue. So I'm going to mark this as correct. Thanks – Harry Apr 05 '17 at 19:48
0

Please check foreach tag for collection attribute. I feel value should be "emList" or add @Param (org.apache.ibatis.annotations.Param) in interface method.

    <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>
Sunny
  • 111
  • 7