I am using queryForList to get a table from my database, which gives me List<Map<String, Object>>. I want to use the two column I select to convert this to a Map<String, Integer>.
At the moment I am doing this
List<Map<String, Object>> customers = jdbc.queryForList("SELECT id, name FROM customers");
Map<String, Integer> customerMap = new HashMap<String, Integer>();
for (Map<String, Object> each : customers)
{
String name = ((String)each.get("name")).trim();
Integer id = Integer.valueOf(((BigDecimal)each.get("id")).intValue());
customerMap.put(name, id);
}
and wondered if there was a better way. Thanks