我正在尝试从Oracle SQL中的存储过程中检索对象列表。你知道我怎么能从下面的代码中得到一个Arraylist?
ArrayList<String> strings = new ArrayList<>();
SimpleJdbcCall jdbcCall = new SimpleJdbcCall(dataSource).withProcedureName("P_ROUTES");
SqlParameterSource in = new MapSqlParameterSource()
.addValue("V_FIXED_INT", period)
.addValue("V_CARRIER", carrier)
.addValue("V_DATE_RANGE_START", dateRangeStart)
.addValue("V_DATE_RANGE_END", dateRangeEnd);
Map<String, Object> out = jdbcCall.execute(in);
ArrayList obj = (ArrayList) out.get("RET_CURSOR");
Map<String, Object> map = (Map<String, Object>) obj.get(0);
答案 0 :(得分:0)
我不确定这是最好的解决方案,但它对我有用。我会尝试找到更好的东西。如果您有任何其他建议,请随意!
Map<String, Object> out = jdbcCall.execute(in);
ArrayList obj = (ArrayList) out.get("RET_CURSOR");
logger.info("Length of retrieved routes from database = " + obj.size());
for (Object o : obj) {
Map<String, Object> map = (Map<String, Object>) o;
for (Map.Entry<String, Object> entry : map.entrySet())
routes.add(entry.getValue().toString());
}