What does SimpleJDBCTemplate.queryForInt do when the database returns null?

What does SimpleJDBCTemplate.queryForInt do when the actual result of the SQL query is null?

In particular, what happens if I run queryForInt("select max(foo) from f") and f has no rows?

While I am dealing with this question, what happens if I run queryForInt("select foo from f") and f has no rows?

+4
source share
1 answer

If the query returns null, the queryForInt method will return 0. However, if the query does not return a row or returns more than one row, queryForInt throws an IncorrectResultSizeDataAccessException exception.

Source

+5
source

Source: https://habr.com/ru/post/1313773/


All Articles