Correctness20 - SpotBugsExtensionForSpringFrameWork/CS5098 GitHub Wiki
Bug Pattern Name: INCORRECT_RESULT_SET_COLUMN_COUNT Short Description: While using JdbcTemplate, we should distinguish queryForList() and query() dependant on single or multiple columns' queries. (IncorrectResultSetColumnCountException)
Description
This exception subclass is thrown when attempting to retrieve multiple columns from a table without creating the proper RowMapper:
@Test(expected = IncorrectResultSetColumnCountException.class)
public void whenRetrievingMultipleColumns_thenIncorrectResultSetColumnCountException() {
JdbcTemplate jdbcTemplate = new JdbcTemplate(restDataSource);
jdbcTemplate.execute("insert into foo(id,name) values (1,'a')");
jdbcTemplate.queryForList("select id,name from foo where id=1", Foo.class);
}