【问题标题】:Expected :Invalid parameter object type Expected'Java.util.List'预期:无效的参数对象类型预期'Java.util.List'
【发布时间】:2015-08-05 02:31:01
【问题描述】:

现在,我想批量更新我的数据,但是当我运行控制台时给出如下:

--- ibatis-config/emptyForIbatisParse_sqlmap.xml中出现错误。
--- 准备执行映射语句时发生错误。
--- 检查 VehQuaCer.updateAmtBal.
--- 原因:java.sql.SQLException:参数对象类型无效。应为“java.util.List”但找到 'app.creditapp.lam.entity.VehQuaCer'.;嵌套异常是 com.ibatis.common.jdbc.exception.NestedSQLException:
--- ibatis-config/emptyForIbatisParse_sqlmap.xml中出现错误。
--- 准备执行映射语句时发生错误。
--- 检查 VehQuaCer.updateAmtBal.
--- 原因:java.sql.SQLException:参数对象类型无效。应为“java.util.List”但找到 'app.creditapp.lam.entity.VehQuaCer'。

我的 DaoImpl 方法如下:

public void updateRelease(final List<VehQuaCer> list) throws DAOException {
        try{
        if(list!=null){
            this.getSqlMapClientTemplate().execute(new SqlMapClientCallback(){
                public Object doInSqlMapClient(SqlMapExecutor executor)throws SQLException{
                    executor.startBatch();
                    for(int i=0,j=list.size();i<j;i++){
                        executor.update("VehQuaCer.updateAmtBal",(VehQuaCer)list.get(i));
                    }
                    executor.executeBatch();
                    return null;
                }
            });
        }
    }catch(Exception e){
        log.error(e);
        throw new DAOException(e.getMessage());
    }

    }

我的ibatis如下:

<update id="VehQuaCer.updateAmtBal" parameterClass="java.util.List">
    begin
    <iterate conjunction="">
    UPDATE VEH_QUA_CER SET REPAY_BAL=#[].repayBal#,SEC_BAL=#[].secBal#,ADV_BAL=#[].advBal#,RELEASE_APP_NO=#[].releaseApp# WHERE ID=#[].id#
    </iterate>
    end;
    </update>

【问题讨论】:

  • 我的 DaoImp 方法如下:' public void updateRelease(final List list) throws DAOException { try{ if(list!=null){ this.getSqlMapClientTemplate().execute(new SqlMapClientCallback (){ public Object doInSqlMapClient(SqlMapExecutor executor)throw SQLException{ executor.startBatch(); for(int i=0,j=list.size();i
  • 编辑您的帖子并将您的代码放在那里。如果您将其放在评论中,则无法阅读。

标签: java spring oracle ibatis


【解决方案1】:

从您提供的代码看来,您的查询期望参数为 List 但因为在您的 DAOImpl 中,如果您已经遍历列表并仅传递“VehQuaCer”对象,因此将参数类更改为具有完整 yqualified 名称的 VehQuaCer应该可以。

【讨论】:

    猜你喜欢
    • 2019-05-18
    • 1970-01-01
    • 2020-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-28
    • 1970-01-01
    • 2022-01-20
    相关资源
    最近更新 更多