5

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

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

While I'm on this subject, what happens if I run queryForInt("select foo from f") and f has no rows?

4

1 に答える 1

5

クエリが null を返す場合、queryForInt メソッドは 0 を返します。ただし、クエリが行を返さないか、複数の行を返す場合、queryForInt は IncorrectResultSizeDataAccessException をスローします。

ソース

于 2010-06-24T16:17:49.650 に答える