Spring JdbcTemplate Query returns empty List instead of Exception -
while running junit test dao method stumbled upon this:
if run autowired jdbctemplate like: jdbctemplate.query(mystatement, new myrowmapper(), myparam1, myparam2) , resultset empty, junit test passes, because myrowmapper not called.
when resultset not empty junit test fails sqlexception because myrowmapper trying access non existing column in resultset.
the problem sql statement wrong in combination myrowmapper depending on 2 params, @ 1 time empty resultset , test fine , other time test fails because there records waiting mapped rowmapper.
so question is: how can (best practice?) junit test jdbctemplate().query(string sql, rowmapper<systemgruppe> rowmapper, object... args) method verify sql statement valid , (!) rowmapper can handle no matter if there records or not?
we use spring-core version: 4.3.7.release
thanks in advance!
Comments
Post a Comment