frustrated with EmptyResultDataAccessException
as we all know "queryForObject" expects one and only one row to be returned.
public <T> T queryForObject(String sql,Object args,RowMapper<T> rowMapper)throws DataAccessException
but why isn't there an equivalent signature 'query' method that would return null if there are no rows found ? From what I can tell all of the 'query' methods return a list or I have to use a RowCallbackHandler.
public <T> T query(String sql,Object args,RowMapper<T> rowMapper)throws DataAccessException
I don't want to implement two mappers or have to check the size of a list. This is really annoying and I don't think totally unreasonable to have a query call that is ok with returning zero objects. Maybe a 'find' call.
Should I query and count first then if the count = 1 I should queryForObject ?
Couldn't queryForObject be overloaded to flag if an exception should be found on no results?