2012-04-22 8 views
2

//設定された入力パラメータPROCEDUREの引数の数が正しくありません。 1予想、カントは、コードからエラーを決定する0を持っ

Map<String,Object> inParams = new HashMap<String,Object>(); 
inParams.put("Sig",resourceHistoryBean.getId()); 

List<ResourceHistoryBean> resourceHistoryList= new ArrayList<ResourceHistoryBean>(); 

//ストアドプロシージャを定義

try{   
    SimpleJdbcCall readResult = new SimpleJdbcCall(getDataSource()) 
      .useInParameterNames("Sig") 
      .declareParameters(new SqlParameter("Sig", Types.VARCHAR)) 
      .withProcedureName("SP_ResourceAllocationDtls") 
      .withSchemaName("hrms") 
      .returningResultSet("ResourceHistory", new ParameterizedRowMapper<ResourceHistoryBean>() { 
       public ResourceHistoryBean mapRow(ResultSet rs, int rowNum) 
         throws SQLException { 
        ResourceHistoryBean bean = new ResourceHistoryBean(); 
        resourceHistoryBean.setProjectName(rs.getString(RH_PROJECT_NAME)); 
        return bean; 
       } 
      }); 
    readResult.compile(); 

//ストアドプロシージャ実行

Map<String, Object> out = readResult.execute(inParams); 
resourceHistoryList = (List<ResourceHistoryBean>) out.get("ResourceHistory"); 

答えて

1

私は上記の問題(ストアドプロシージャに渡すパラメータと同様にマッピングクラスを使用する)の代替ソリューションを見つけることができたように見えます:

public List<ResourceHistoryBean> getResourceHistory(final ResourceHistoryBean resourceHistoryBean)throws Exception{ 

    try { 
     // call stored procedure and pass parameter to it 
     List resourceHistoryList = getJdbcTemplate().query(
       "call hrms.SP_ResourceAllocationDtls(?)", 
       new Object[] {resourceHistoryBean.getId()}, new HistoryMapper()); 
     return resourceHistoryList; 
    } catch (Exception e) { 
     throw e; 
    } finally { 
     closeTemplate(); 

    } 

} 

//マッパークラス

class HistoryMapper implements RowMapper, IDatabaseConstants { 

public Object mapRow(ResultSet rs, int rowNum) throws SQLException { 
    ResourceHistoryBean resourceHistoryBean = new ResourceHistoryBean(); 
    resourceHistoryBean.setProjectName(rs.getString(RH_PROJECT_NAME)); 
    return resourceHistoryBean; 
} 
} 
関連する問題