diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java index c041af56b4..7ce4110575 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java @@ -388,4 +388,16 @@ public class BeanPropertyRowMapper implements RowMapper { 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 BeanPropertyRowMapper newInstance(Class mappedClass, @Nullable ConversionService conversionService) { + BeanPropertyRowMapper rowMapper = newInstance(mappedClass); + rowMapper.setConversionService(conversionService); + return rowMapper; + } + }