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:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2009 the original author or authors.
|
||||
* Copyright 2008-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.
|
||||
@@ -25,8 +25,8 @@ import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.database.JdbcCursorItemReader;
|
||||
import org.springframework.batch.item.database.support.ListPreparedStatementSetter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.ArgumentPreparedStatementSetter;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -64,7 +64,7 @@ public class JdbcCursorItemReaderPreparedStatementIntegrationTests {
|
||||
List<Long> parameters = new ArrayList<>();
|
||||
parameters.add(1L);
|
||||
parameters.add(4L);
|
||||
ListPreparedStatementSetter pss = new ListPreparedStatementSetter(parameters);
|
||||
ArgumentPreparedStatementSetter pss = new ArgumentPreparedStatementSetter(parameters.toArray());
|
||||
|
||||
itemReader.setPreparedStatementSetter(pss);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017 the original author or authors.
|
||||
* Copyright 2017-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.
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.springframework.batch.item.database.builder;
|
||||
|
||||
import java.util.Collections;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.After;
|
||||
@@ -28,13 +27,13 @@ import test.jdbc.datasource.DerbyShutdownBean;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.database.FooRowMapper;
|
||||
import org.springframework.batch.item.database.StoredProcedureItemReader;
|
||||
import org.springframework.batch.item.database.support.ListPreparedStatementSetter;
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.jdbc.core.ArgumentPreparedStatementSetter;
|
||||
import org.springframework.jdbc.core.SqlParameter;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
@@ -47,6 +46,7 @@ import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* @author Michael Minella
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
public class StoredProcedureItemReaderBuilderTests {
|
||||
|
||||
@@ -87,7 +87,7 @@ public class StoredProcedureItemReaderBuilderTests {
|
||||
|
||||
@Test
|
||||
public void testConfiguration() {
|
||||
ListPreparedStatementSetter preparedStatementSetter = new ListPreparedStatementSetter(Collections.EMPTY_LIST);
|
||||
ArgumentPreparedStatementSetter preparedStatementSetter = new ArgumentPreparedStatementSetter(null);
|
||||
|
||||
SqlParameter[] parameters = new SqlParameter[0];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user