public List<ColorModel> getAllColor() {
String query = "SELECT * FROM COLOR";
List<ColorModel> colors = getjdbcTemplate().query(query, new ColorMapper());
return colors;
}
class ColorMapper implements RowMapper<Color> {
public ColorModel mapRow(ResultSet rs, int rowNum) throws SQLException {
ColorModel color = new ColorModel ();
color.setId(rs.getInt("ID"));
color.setName(rs.getString("color_name"));
}
}
问题
我怎么能宁愿返回LinkedHashMap<Integer, String>
而不是List<ColorModel>