Add beanRowMapper to JdbcPagingItemReaderBuilder

Sets the rowMapper of the JdbcPagingItemReader as
a BeanPropertyRowMapper.

Issue #819
This commit is contained in:
Drummond Dawson
2019-01-16 21:28:40 -05:00
committed by Mahmoud Ben Hassine
parent e3bc7ded37
commit 8a6a2bd19a
2 changed files with 49 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017 the original author or authors.
* Copyright 2017-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,6 +33,7 @@ import org.springframework.batch.item.database.support.SqlServerPagingQueryProvi
import org.springframework.batch.item.database.support.SqlitePagingQueryProvider;
import org.springframework.batch.item.database.support.SybasePagingQueryProvider;
import org.springframework.batch.support.DatabaseType;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.support.MetaDataAccessException;
import org.springframework.util.Assert;
@@ -46,6 +47,7 @@ import org.springframework.util.Assert;
*
* @author Michael Minella
* @author Glenn Renfro
* @author Drummond Dawson
* @since 4.0
* @see JdbcPagingItemReader
*/
@@ -175,6 +177,20 @@ public class JdbcPagingItemReaderBuilder<T> {
return this;
}
/**
* Creates a {@link BeanPropertyRowMapper} to be used as your
* {@link RowMapper}.
*
* @param mappedClass the class for the row mapper
* @return this instance for method chaining
* @see BeanPropertyRowMapper
*/
public JdbcPagingItemReaderBuilder<T> beanRowMapper(Class<T> mappedClass) {
this.rowMapper = new BeanPropertyRowMapper<>(mappedClass);
return this;
}
/**
* A {@link Map} of values to set on the SQL's prepared statement.
*