Add BeanPropertyRowMapper.newInstance(mappedClass, conversionService)

Similar to SingleColumnRowMapper.newInstance(requiredType,
conversionService) which was added in #1678.
This commit is contained in:
perceptron8 2019-12-12 12:17:02 +01:00 committed by Juergen Hoeller
parent d757f73902
commit dafe57fc6e
1 changed files with 12 additions and 0 deletions

View File

@ -388,4 +388,16 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
return new BeanPropertyRowMapper<>(mappedClass);
}
/**
* Static factory method to create a new {@code BeanPropertyRowMapper}
* (with the required type specified only once).
* @param mappedClass the class that each row should be mapped to
* @param conversionService the {@link ConversionService} for binding JDBC values to bean properties, or {@code null} for none
*/
public static <T> BeanPropertyRowMapper<T> newInstance(Class<T> mappedClass, @Nullable ConversionService conversionService) {
BeanPropertyRowMapper<T> rowMapper = newInstance(mappedClass);
rowMapper.setConversionService(conversionService);
return rowMapper;
}
}