Custom RowMapper
Learn how to use the RowMapper interface to define the row mapper.
We'll cover the following
The BeanPropertyRowMapper
can be used to map the results of the query to our bean. If the database table has a different structure or column names, we need to define our custom mapping.
RowMapper
interface
We can define our own row mapper in the PlayerDao
class by implementing the RowMapper
interface and providing the bean onto which the rows will be mapped. The custom row mapper, PlayerMapper
is created as an inner class because it will only be used inside JdbcPlayerDao
. It is best practice to make it static
and final
.
Get hands-on with 1400+ tech skills courses.