Handy RowMapper base class for Spring JDBC
RowMappers are needed all over the place in your Spring JDBC DAO classes. One challenge that I kept running into was that when I wanted to reuse a particular RowMapper
class for numerous queries, there was an ever-present threat of an underlying SQLException
if certain columns were not present in the ResultSet
. Obviously, a reusable RowMapper
will set every field on the object it maps for, however not every ResultSet
will include every field. Calling rs.getString("column_name");
will result in an exception being thrown if column_name
is not present in the particular ResultSet
.
So to solve this problem, I wrote this base RowMapper
class:
Read more