Fixed Object attribute handling in JdbcStepExecutionDao (were being put as Longs into execution context)
This commit is contained in:
@@ -40,7 +40,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* <p>
|
||||
* Implementation of {@link JobRepository} that stores JobInstances,
|
||||
* JobExecutions, StepInstances, and StepExecutions using the injected DAOs.
|
||||
* JobExecutions, and StepExecutions using the injected DAOs.
|
||||
* <p>
|
||||
*
|
||||
* @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);
|
||||
|
||||
@@ -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: ["
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user