From dafe57fc6e1b019fe011fcdf99f32f9b11c01bb0 Mon Sep 17 00:00:00 2001 From: perceptron8 Date: Thu, 12 Dec 2019 12:17:02 +0100 Subject: [PATCH] Add BeanPropertyRowMapper.newInstance(mappedClass, conversionService) Similar to SingleColumnRowMapper.newInstance(requiredType, conversionService) which was added in #1678. --- .../jdbc/core/BeanPropertyRowMapper.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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; + } + }