2015-12-14 79 views
3

我試圖插入一個列表的MyBatis和獲取foloowing錯誤:MyBatis的BindingException參數「__frch_e_0」未找到

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

你設法解決它嗎? – Arsen

+0

對不起@Arsen ....不。我不得不單獨插入....不會影響性能,因爲數據大小很小 – Harry

回答

1
  • 檢查列名和SQL bean字段名

  • 嘗試更新的MyBatis版本。當我使用3.3.0有這個錯誤,但使用3.4.1它沒事

+0

對不起,遲到的迴應...但升級版本到3.4.2修復了問題,所以我打算將它標記爲正確。 – Harry

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> 
+0

感謝您的回答,但仍然無效:( – Harry

+0

void saveList(@Param(「emList」)List emList); – Harry

+0

\t ... – Harry

相關問題