s****e 发帖数: 19 | 1 I used the following method from JdbcTemplate class:
public long queryForLong(String sql, Object[] args) throws
DataAccessException
From the API, it says if the query returns null, the method returns a 0.
However, I tried all that I can to see what the value is returned from this
method, I couldn't get anything. It seems like if the query returns null,
this method doesn't return at all.
Has anyone have the same problem before? | g*****g 发帖数: 34805 | 2 What do you mean not return at all?
If an exception is throwed, that's not a surprise.
this
【在 s****e 的大作中提到】 : I used the following method from JdbcTemplate class: : public long queryForLong(String sql, Object[] args) throws : DataAccessException : From the API, it says if the query returns null, the method returns a 0. : However, I tried all that I can to see what the value is returned from this : method, I couldn't get anything. It seems like if the query returns null, : this method doesn't return at all. : Has anyone have the same problem before?
| A**o 发帖数: 1550 | 3 are you using debugger? where it goes if not returning?
this
【在 s****e 的大作中提到】 : I used the following method from JdbcTemplate class: : public long queryForLong(String sql, Object[] args) throws : DataAccessException : From the API, it says if the query returns null, the method returns a 0. : However, I tried all that I can to see what the value is returned from this : method, I couldn't get anything. It seems like if the query returns null, : this method doesn't return at all. : Has anyone have the same problem before?
| s****e 发帖数: 19 | 4 Ah... I just realized that following exception is thrown:
org.springframework.dao.EmptyResultDataAccessException: Incorrect result
size: expected 1, actual 0
However, I am still not quite sure how to use QueryForLong() in the case
when sql returns null.
Thanks for helping. | m******t 发帖数: 2416 | 5 queryForLong only handles a null value returned in the target column on an _
actual_ result row, but not an empty result set. From the exception, it
looks like that's what your sql is returning. | s****e 发帖数: 19 | 6 hmm.. that really makes sense. Thanks so much! |
|