Hi,
I think I'm almost there but the last few steps ahve got me stumped!!!
I am writing an inner class that returns a Map of key/value pairs. Here's my code so far:
the first method getBranches() doesnt call the inner class yet and instead constructs the map manually. Its this map I want to create in the inner class. I've seen a lot of examples of using RowMapper but they all write to System.out. How can I return a map like I want to?Code:public Map getBranches() { logger.info("Entering method QueryDaoImpl.getBranches"); Map branches = new HashMap(); branches.put("1", "London"); branches.put("2", "Madrid"); branches.put("3", "Barcelona"); branches.put("4", "New York"); logger.info("Exiting method QueryDaoImpl.getBranches"); return branches; } private class GetBranchesSP extends StoredProcedure { private static final String SQL = "PKG_PBTV_UILOOKUP.F_PBTVBRANCHESGET"; public GetBranchesSP(DataSource ds) { setDataSource(ds); setSql(SQL); setFunction(true); declareParameter(new SqlOutParameter("cursor", OracleTypes.CURSOR,new RowMapper(){ public Object mapRow(ResultSet rs, int rowNum) throws SQLException { logger.info("Entering method .mapRow"); // TODO implement method logger.info("Exiting method .mapRow"); return null; } })); compile(); } public Map execute() { Map results = execute(new HashMap()); return results; } }
The cursor will hold a variable number of rows and each row has 2 strings (id and value - for populating a html drop down).
Thanks in advance,
Rakesh


Reply With Quote