Often in time I use jdbcTemplate.query not to return a resultset but to access the DB and do some computations on each record selected. For example the code below works
Map<String, Double> mAcc = new HashMap<>();
sql = "select ar.id_codice_art, sum(ar.quantita) quantita\n" +
"from accettazione a \n" +
"inner join accettazione_riga ar on a.id_accettazione = ar.id_accettazione\n" +
"where a.id_ordine = ? \n" +
"group by ar.id_codice_art";
jdbcTemplate.query(sql, (rs, i)->{
mAcc.put(rs.getString("id_codice_art"), rs.getDouble("quantita"));
return "";
}, idOrdine);
but it's not clean especially when a return "" because it is required by RowMapper interface. At the same time I don't want to create a record or a class just to return a list and work on the list.
Is there a better way to do the same think using jdbcTemplate?