ParameterizedRowMapper or RowMapper recommended

I am very new to Spring JDBC and working on the task, looking at the codes that we already have, my teammates used RowMapper, but I did some actions on Google and saw some tutorials using ParameterizedRowMapper, so I was wondering if there is any Either good or good practice in using one and not the other, and your technical thoughts are behind it ...

thanks.

+1
source share
2 answers

Prior to Spring 3.0, most APIs did not use generics because Java 1.5 was not required. The result was RowMapper, which did not support generics and ParameterizedRowMapper, which supported generics, extending RowMapper and adding a generic parameter. Starting with Spring 3.0, most of the APIs have been updated to support generics. If you really look at the current (3.0 or higher) definition of ParameterizedRowMapper, it just simply extends RowMapper and doesn't add anything to the definition to provide backward compatibility. Therefore, you can pretty much use RowMapper, parameterized or not, and you don't need to use the ParameterizedRowMapper parameter.

+2
source

Straight from javadoc parameter ParameterizedRowMapper :

Extension of the RowMapper interface, adding type parameterization. In view from Spring 3.0, this is equivalent to using the RowMapper interface directly.

+3
source

Source: https://habr.com/ru/post/976059/


All Articles