Deprecate ListPreparedStatementSetter in favor of ArgumentPreparedStatementSetter

ListPreparedStatementSetter is almost a duplicate of
ArgumentPreparedStatementSetter except that it accepts a List of
arguments instead of an array of arguments.

Resolves BATCH-2796
This commit is contained in:
Mahmoud Ben Hassine
2019-09-27 10:59:52 +02:00
parent 2306141826
commit 5b46c919ea
4 changed files with 18 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2018 the original author or authors.
* Copyright 2016-2019 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.
@@ -20,8 +20,6 @@ import javax.sql.DataSource;
import org.springframework.batch.item.database.AbstractCursorItemReader;
import org.springframework.batch.item.database.JdbcCursorItemReader;
import org.springframework.batch.item.database.support.ListPreparedStatementSetter;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.jdbc.core.ArgumentPreparedStatementSetter;
import org.springframework.jdbc.core.ArgumentTypePreparedStatementSetter;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
@@ -36,6 +34,7 @@ import org.springframework.util.StringUtils;
* @author Michael Minella
* @author Glenn Renfro
* @author Drummond Dawson
* @author Mahmoud Ben Hassine
* @since 4.0
*/
public class JdbcCursorItemReaderBuilder<T> {
@@ -274,14 +273,10 @@ public class JdbcCursorItemReaderBuilder<T> {
*
* @param args values to set on the query
* @return this instance for method chaining
* @throws Exception from {@link InitializingBean#afterPropertiesSet()}
*/
public JdbcCursorItemReaderBuilder<T> queryArguments(List<?> args) throws Exception {
ListPreparedStatementSetter listPreparedStatementSetter = new ListPreparedStatementSetter(args);
listPreparedStatementSetter.afterPropertiesSet();
this.preparedStatementSetter = listPreparedStatementSetter;
public JdbcCursorItemReaderBuilder<T> queryArguments(List<?> args) {
Assert.notNull(args, "The list of arguments must not be null");
this.preparedStatementSetter = new ArgumentPreparedStatementSetter(args.toArray());
return this;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2013 the original author or authors.
* Copyright 2006-2019 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.
@@ -35,9 +35,14 @@ import org.springframework.util.Assert;
* item in the list will be the first bind variable set. (i.e. it will
* correspond to the first '?' in the SQL statement)
*
* @deprecated use {@link org.springframework.jdbc.core.ArgumentPreparedStatementSetter}
* instead.
*
* @author Lucas Ward
* @author Mahmoud Ben Hassine
*
*/
@Deprecated
public class ListPreparedStatementSetter implements
PreparedStatementSetter, InitializingBean {