diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/resource/StepExecutionPreparedStatementSetter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/resource/StepExecutionPreparedStatementSetter.java index 32a2dba55..cf95a9821 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/resource/StepExecutionPreparedStatementSetter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/resource/StepExecutionPreparedStatementSetter.java @@ -24,7 +24,6 @@ import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.StepExecutionListener; import org.springframework.batch.core.listener.StepExecutionListenerSupport; -import org.springframework.batch.item.ExecutionContext; import org.springframework.beans.factory.InitializingBean; import org.springframework.jdbc.core.PreparedStatementSetter; import org.springframework.jdbc.core.SqlTypeValue; @@ -44,18 +43,13 @@ public class StepExecutionPreparedStatementSetter extends StepExecutionListenerS private List parameterKeys; private JobParameters jobParameters; - private ExecutionContext executionContext; public void setValues(PreparedStatement ps) throws SQLException { Map parameters = jobParameters.getParameters(); for(int i = 0; i < parameterKeys.size(); i++){ - String parameterKey = parameterKeys.get(i).toString(); - Object arg = executionContext.get(parameterKey); + Object arg = parameters.get(parameterKeys.get(i)); if(arg == null){ - arg = parameters.get(parameterKey); - if(arg == null){ - throw new IllegalStateException("No job parameter found for with key of: [" + parameterKeys.get(i) + "]"); - } + throw new IllegalStateException("No job parameter found for with key of: [" + parameterKeys.get(i) + "]"); } StatementCreatorUtils.setParameterValue(ps, i + 1, SqlTypeValue.TYPE_UNKNOWN, arg); } @@ -63,7 +57,6 @@ public class StepExecutionPreparedStatementSetter extends StepExecutionListenerS public void beforeStep(StepExecution stepExecution) { this.jobParameters = stepExecution.getJobParameters(); - this.executionContext = stepExecution.getExecutionContext(); } /** diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/JobParametersPreparedStatementSetterTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/StepExecutionPreparedStatementSetterTests.java similarity index 80% rename from spring-batch-core/src/test/java/org/springframework/batch/core/resource/JobParametersPreparedStatementSetterTests.java rename to spring-batch-core/src/test/java/org/springframework/batch/core/resource/StepExecutionPreparedStatementSetterTests.java index a1bd13964..567a4596b 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/JobParametersPreparedStatementSetterTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/StepExecutionPreparedStatementSetterTests.java @@ -27,7 +27,6 @@ import org.springframework.batch.core.JobParametersBuilder; import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.job.SimpleJob; import org.springframework.batch.core.step.tasklet.TaskletStep; -import org.springframework.batch.item.ExecutionContext; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowCallbackHandler; import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests; @@ -36,7 +35,7 @@ import org.springframework.test.AbstractTransactionalDataSourceSpringContextTest * @author Lucas Ward * */ -public class JobParametersPreparedStatementSetterTests extends AbstractTransactionalDataSourceSpringContextTests { +public class StepExecutionPreparedStatementSetterTests extends AbstractTransactionalDataSourceSpringContextTests { JdbcTemplate jdbcTemplate; StepExecutionPreparedStatementSetter pss; @@ -106,27 +105,4 @@ public class JobParametersPreparedStatementSetterTests extends AbstractTransacti } } - - public void testMixedProperties(){ - - ExecutionContext executionContext = new ExecutionContext(); - executionContext.putLong("begin.id", 2); - stepExecution.setExecutionContext(executionContext); - pss.beforeStep(stepExecution); - - List parameterNames = new ArrayList(); - parameterNames.add("begin.id"); - parameterNames.add("end.id"); - pss.setParameterKeys(parameterNames); - - final List results = new ArrayList(); - jdbcTemplate.query("SELECT NAME from T_FOOS where ID > ? and ID < ?", pss, new RowCallbackHandler(){ - - public void processRow(ResultSet rs) throws SQLException { - results.add(rs.getString(1)); - }}); - - assertEquals(1, results.size()); - assertEquals("bar3", results.get(0)); - } }