Custom RowMapper

Learn how to use the RowMapper interface to define the row mapper.

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 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.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.