diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java index c1e92950a..55d938432 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java @@ -40,7 +40,7 @@ import org.springframework.util.Assert; * *

* Implementation of {@link JobRepository} that stores JobInstances, - * JobExecutions, StepInstances, and StepExecutions using the injected DAOs. + * JobExecutions, and StepExecutions using the injected DAOs. *

* * @author Lucas Ward @@ -50,7 +50,6 @@ import org.springframework.util.Assert; * @see JobRepository * @see JobInstanceDao * @see JobExecutionDao - * @see StepInstanceDao * @see StepExecutionDao * */ @@ -269,6 +268,9 @@ public class SimpleJobRepository implements JobRepository { } } + /** + * @return the last execution of the step within given job instance + */ public StepExecution getLastStepExecution(JobInstance jobInstance, Step step) { List jobExecutions = jobExecutionDao.findJobExecutions(jobInstance); List stepExecutions = new ArrayList(jobExecutions.size()); @@ -292,6 +294,9 @@ public class SimpleJobRepository implements JobRepository { return latest; } + /** + * @return number of executions of the step within given job instance + */ public int getStepExecutionCount(JobInstance jobInstance, Step step) { int count = 0; List jobExecutions = jobExecutionDao.findJobExecutions(jobInstance); diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcStepExecutionDao.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcStepExecutionDao.java index d8f643dc4..9592bae03 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcStepExecutionDao.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcStepExecutionDao.java @@ -106,7 +106,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement executionContext.putDouble(key, rs.getDouble("DOUBLE_VAL")); } else if (type == AttributeType.OBJECT) { - executionContext.putLong(key, rs.getLong("OBJECT_VAL")); + executionContext.put(key, rs.getObject("OBJECT_VAL")); } else { throw new BatchCriticalException("Invalid type found: [" + typeCd + "] for execution id: [" diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractStepDaoTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractStepDaoTests.java index 41cc5ef87..28e2882b5 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractStepDaoTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractStepDaoTests.java @@ -16,7 +16,10 @@ package org.springframework.batch.execution.repository.dao; +import java.io.Serializable; +import java.util.ArrayList; import java.util.Date; +import java.util.List; import org.springframework.batch.core.domain.BatchStatus; import org.springframework.batch.core.domain.Job; @@ -191,11 +194,15 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour } public void testSaveExecutionContext(){ + stepExecution.setExecutionContext(executionContext); stepExecutionDao.saveExecutionContext(stepExecution); ExecutionContext attributes = stepExecutionDao.findExecutionContext(stepExecution); assertEquals(executionContext, attributes); executionContext.putString("newString", "newString"); + executionContext.putLong("newLong", 1); + executionContext.putDouble("newDouble", 2.5); + executionContext.put("newSerializable", "serializableValue"); stepExecutionDao.updateExecutionContext(stepExecution); attributes = stepExecutionDao.findExecutionContext(stepExecution); assertEquals(executionContext, attributes);