Browse Source

Add BeanPropertyRowMapper.newInstance(mappedClass, conversionService)

Similar to SingleColumnRowMapper.newInstance(requiredType,
conversionService) which was added in #1678.
pull/24200/head
perceptron8 5 years ago committed by Juergen Hoeller
parent
commit
dafe57fc6e
  1. 12
      spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java

12
spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java

@ -388,4 +388,16 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> { @@ -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;
}
}

Loading…
Cancel
Save