spring StoredProcedure 结果集返回问题

问题:
Results returned from stored procedure but a corresponding SqlOutParameter/SqlReturnResultSet parameter was not declared" when calling the store procedure. I am not getting any values from result set.

示例代码片段如下:
protected class FundProcess extends StoredProcedure{
  public static final String FUND = "FST_GETFUNDBYAMCID";

  public FundProcess(DataSource ds){
    setDataSource(ds);
    setSql(FUND);
    setFunction(false);
    declareParameter(new SqlParameter("FUND_ID", Types.INTEGER));
    declareParameter(new SqlReturnResultSet("rows", new FundMapper()));
    compile();
  }
}

解决方法:
将这两条语句顺序颠倒即可,存储过程返回结果集设置一定放到最后设置。
    declareParameter(new SqlParameter("FUND_ID", Types.INTEGER));
    declareParameter(new SqlReturnResultSet("rows", new FundMapper()));

你可能感兴趣的:(spring)