RESOLVED - BATCH-595: Incorrect JDBC type for job parameters of long type
used Types.BIGINT instead of Types.INTEGER for Long values
This commit is contained in:
@@ -136,8 +136,8 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
|
||||
private void insertParameter(Long jobId, ParameterType type, String key, Object value) {
|
||||
|
||||
Object[] args = new Object[0];
|
||||
int[] argTypes = new int[] { Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP,
|
||||
Types.INTEGER, Types.DOUBLE };
|
||||
int[] argTypes = new int[] { Types.BIGINT, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP,
|
||||
Types.BIGINT, Types.DOUBLE };
|
||||
|
||||
if (type == ParameterType.STRING) {
|
||||
args = new Object[] { jobId, key, type, value, new Timestamp(0L), new Long(0), new Double(0) };
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.springframework.batch.core.repository.dao;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
@@ -9,11 +11,15 @@ import org.springframework.test.AbstractTransactionalDataSourceSpringContextTest
|
||||
|
||||
public abstract class AbstractJobInstanceDaoTests extends AbstractTransactionalDataSourceSpringContextTests {
|
||||
|
||||
private static final long DATE = 777;
|
||||
|
||||
private JobInstanceDao dao = new MapJobInstanceDao();
|
||||
|
||||
private Job fooJob = new JobSupport("foo");
|
||||
|
||||
private JobParameters fooParams = new JobParametersBuilder().addString("fooKey", "fooValue").toJobParameters();
|
||||
private JobParameters fooParams = new JobParametersBuilder().addString("stringKey", "stringValue").addLong(
|
||||
"longKey", new Long(Long.MAX_VALUE)).addDouble("doubleKey", new Double(Double.MAX_VALUE)).addDate(
|
||||
"dateKey", new Date(DATE)).toJobParameters();
|
||||
|
||||
protected abstract JobInstanceDao getJobInstanceDao();
|
||||
|
||||
@@ -32,7 +38,15 @@ public abstract class AbstractJobInstanceDaoTests extends AbstractTransactionalD
|
||||
assertEquals(fooParams, fooInstance.getJobParameters());
|
||||
|
||||
JobInstance retrievedInstance = dao.getJobInstance(fooJob, fooParams);
|
||||
JobParameters retrievedParams = retrievedInstance.getJobParameters();
|
||||
assertEquals(fooInstance, retrievedInstance);
|
||||
assertEquals(fooJob, retrievedInstance.getJob());
|
||||
assertEquals(fooParams, retrievedParams);
|
||||
|
||||
assertEquals(Long.MAX_VALUE, retrievedParams.getLong("longKey").longValue());
|
||||
assertEquals(Double.MAX_VALUE, retrievedParams.getDouble("doubleKey").doubleValue(), 0.001);
|
||||
assertEquals("stringValue", retrievedParams.getString("stringKey"));
|
||||
assertEquals(new Date(DATE), retrievedParams.getDate("dateKey"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,4 +75,5 @@ public abstract class AbstractJobInstanceDaoTests extends AbstractTransactionalD
|
||||
|
||||
assertNotNull(jobInstance.getVersion());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user