From 2f3cf7bec0f96bcf70984e04f9f4db850afca68c Mon Sep 17 00:00:00 2001 From: robokaso Date: Wed, 27 Feb 2008 11:19:45 +0000 Subject: [PATCH] RESOLVED - issue BATCH-287: add double job parameter type http://jira.springframework.org/browse/BATCH-287 --- .../batch/core/domain/JobParameters.java | 75 +++++++++++++------ .../core/domain/JobParametersBuilder.java | 20 ++++- .../batch/core/domain/JobParametersTests.java | 46 ++++++++++-- .../repository/dao/JdbcJobInstanceDao.java | 30 ++++++-- .../src/main/resources/schema-db2.sql | 3 +- .../src/main/resources/schema-derby.sql | 3 +- .../src/main/resources/schema-hsqldb.sql | 3 +- .../src/main/resources/schema-mysql.sql | 3 +- .../src/main/resources/schema-oracle10g.sql | 3 +- .../src/main/resources/schema-postgresql.sql | 3 +- .../src/main/sql/init.sql.vpp | 3 +- .../SimpleJobRepositoryIntegrationTests.java | 7 +- .../repository/dao/AbstractJobDaoTests.java | 6 +- .../batch/execution/repository/dao/init.sql | 3 +- 14 files changed, 157 insertions(+), 51 deletions(-) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobParameters.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobParameters.java index 76f128c99..b49fa68a4 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobParameters.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobParameters.java @@ -13,11 +13,13 @@ import java.util.Map.Entry; import org.apache.commons.lang.builder.HashCodeBuilder; /** - * Value object representing runtime parameters to a batch job. Because the parameters have no individual meaning - * outside of the JobIdentifier they are contained within, it is a value object rather than an entity. It is also - * extremely important that a parameters object can be reliably compared to another for equality, in order to determine - * if one JobIdentifier equals another. Furthermore, because these parameters will need to be persisted, it is vital - * that the types added are restricted. + * Value object representing runtime parameters to a batch job. Because the + * parameters have no individual meaning outside of the JobParameters they are + * contained within, it is a value object rather than an entity. It is also + * extremely important that a parameters object can be reliably compared to + * another for equality, in order to determine if one JobParameters object + * equals another. Furthermore, because these parameters will need to be + * persisted, it is vital that the types added are restricted. * * @author Lucas Ward * @since 1.0 @@ -28,34 +30,37 @@ public class JobParameters { private final Map longMap; + private final Map doubleMap; + private final Map dateMap; /** - * Default constructor. Creates a new empty JobRuntimeParameters. It should be noted that this constructor should - * only be used if an empty parameters is needed, since JobRuntimeParameters is immutable. + * Default constructor. Creates a new empty JobRuntimeParameters. It should + * be noted that this constructor should only be used if an empty parameters + * is needed, since JobRuntimeParameters is immutable. */ public JobParameters() { this.stringMap = new LinkedHashMap(); this.longMap = new LinkedHashMap(); + this.doubleMap = new LinkedHashMap(); this.dateMap = new LinkedHashMap(); } /** - * Create a new parameters object based upon three maps for each of the three data types. See - * {@link JobParametersBuilder} for an easier way to create parameters. - * - * @param stringMap - * @param longMap - * @param dateMap + * Create a new parameters object based upon the maps for each of the + * supported data types. See {@link JobParametersBuilder} for an easier way + * to create parameters. */ - public JobParameters(Map stringMap, Map longMap, Map dateMap) { + public JobParameters(Map stringMap, Map longMap, Map doubleMap, Map dateMap) { super(); validateMap(stringMap, String.class); validateMap(longMap, Long.class); + validateMap(doubleMap, Double.class); validateMap(dateMap, Date.class); this.stringMap = new LinkedHashMap(stringMap); this.longMap = new LinkedHashMap(longMap); + this.doubleMap = new LinkedHashMap(doubleMap); this.dateMap = copyDateMap(dateMap); } @@ -79,6 +84,16 @@ public class JobParameters { return (Long) longMap.get(key); } + /** + * Typesafe Getter for the Long represented by the provided key. + * + * @param key The key to get a value for + * @return The Double value + */ + public Double getDouble(String key) { + return (Double) doubleMap.get(key); + } + /** * Typesafe Getter for the Date represented by the provided key. * @@ -90,14 +105,16 @@ public class JobParameters { } /** - * Get a map of all parameters, including string, long, and date. It should be noted that a - * Collections$UnmodifiableMap is returned, ensuring immutability. + * Get a map of all parameters, including string, long, and date. It should + * be noted that a Collections$UnmodifiableMap is returned, ensuring + * immutability. * * @return an unmodifiable map containing all parameters. */ public Map getParameters() { Map tempMap = new LinkedHashMap(stringMap); tempMap.putAll(longMap); + tempMap.putAll(doubleMap); tempMap.putAll(dateMap); return Collections.unmodifiableMap(tempMap); } @@ -120,6 +137,15 @@ public class JobParameters { return Collections.unmodifiableMap(longMap); } + /** + * Get a map of only Double parameters + * + * @return long parameters. + */ + public Map getDoubleParameters() { + return Collections.unmodifiableMap(doubleMap); + } + /** * Get a map of only Date parameters * @@ -133,12 +159,12 @@ public class JobParameters { * @return true if the prameters is empty, false otherwise. */ public boolean isEmpty() { - return (dateMap.isEmpty() && longMap.isEmpty() && stringMap.isEmpty()); + return (dateMap.isEmpty() && longMap.isEmpty() && doubleMap.isEmpty() && stringMap.isEmpty()); } /* - * Convenience method for validating that a the provided map only contains a particular type as a value, with only a - * String as a key. + * Convenience method for validating that a the provided map only contains a + * particular type as a value, with only a String as a key. */ private void validateMap(Map map, Class type) { @@ -181,20 +207,23 @@ public class JobParameters { JobParameters parameters = (JobParameters) obj; - // Since the type contained by each map is known, it's safe to call Map.equals() + // Since the type contained by each map is known, it's safe to call + // Map.equals() if (getParameters().equals(parameters.getParameters())) { return true; - } else { + } + else { return false; } } public int hashCode() { - return new HashCodeBuilder(7, 21).append(stringMap).append(longMap).append(dateMap).toHashCode(); + return new HashCodeBuilder(7, 21).append(stringMap).append(longMap).append(doubleMap).append(dateMap) + .toHashCode(); } public String toString() { - return stringMap.toString() + longMap.toString() + dateMap.toString(); + return stringMap.toString() + longMap.toString() + doubleMap.toString() + dateMap.toString(); } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobParametersBuilder.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobParametersBuilder.java index 53a8e36f2..312856c8a 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobParametersBuilder.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobParametersBuilder.java @@ -26,6 +26,8 @@ public class JobParametersBuilder { private final Map stringMap; private final Map longMap; + + private final Map doubleMap; private final Map dateMap; @@ -36,6 +38,7 @@ public class JobParametersBuilder { this.stringMap = new LinkedHashMap(); this.longMap = new LinkedHashMap(); + this.doubleMap = new LinkedHashMap(); this.dateMap = new LinkedHashMap(); } @@ -70,13 +73,26 @@ public class JobParametersBuilder { * * @param key - parameter accessor. * @param parameter - runtime parameter - * @return a refernece to this object. + * @return a reference to this object. */ public JobParametersBuilder addLong(String key, Long parameter) { Assert.notNull(parameter, "Parameter must not be null."); longMap.put(key, parameter); return this; } + + /** + * Add a new Double parameter for the given key. + * + * @param key - parameter accessor. + * @param parameter - runtime parameter + * @return a reference to this object. + */ + public JobParametersBuilder addDouble(String key, Double parameter) { + Assert.notNull(parameter, "Parameter must not be null."); + doubleMap.put(key, parameter); + return this; + } /** * Conversion method that takes the current state of this builder and @@ -85,6 +101,6 @@ public class JobParametersBuilder { * @return a valid JobRuntimeParameters object. */ public JobParameters toJobParameters() { - return new JobParameters(stringMap, longMap, dateMap); + return new JobParameters(stringMap, longMap, doubleMap, dateMap); } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobParametersTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobParametersTests.java index ca8fa62d3..72043f566 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobParametersTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobParametersTests.java @@ -24,6 +24,8 @@ public class JobParametersTests extends TestCase { Map longMap; Map dateMap; + + Map doubleMap; Date date1 = new Date(4321431242L); @@ -43,12 +45,16 @@ public class JobParametersTests extends TestCase { longMap = new HashMap(); longMap.put("long.key1", new Long(1)); longMap.put("long.key2", new Long(2)); + + doubleMap = new HashMap(); + doubleMap.put("double.key1", new Double(1.1)); + doubleMap.put("double.key2", new Double(2.2)); dateMap = new HashMap(); dateMap.put("date.key1", date1); dateMap.put("date.key2", date2); - return new JobParameters(stringMap, longMap, dateMap); + return new JobParameters(stringMap, longMap, doubleMap, dateMap); } public void testBadLongKeyException() throws Exception { @@ -57,7 +63,7 @@ public class JobParametersTests extends TestCase { badLongMap.put(new Long(0), new Long(1)); try { - new JobParameters(stringMap, badLongMap, dateMap); + new JobParameters(stringMap, badLongMap, doubleMap, dateMap); fail(); } catch (IllegalArgumentException ex) { @@ -71,7 +77,21 @@ public class JobParametersTests extends TestCase { badLongMap.put("key", "bad long"); try { - new JobParameters(stringMap, badLongMap, dateMap); + new JobParameters(stringMap, badLongMap, doubleMap, dateMap); + fail(); + } + catch (IllegalArgumentException ex) { + // expected + } + } + + public void testBadDoubleConstructorException() throws Exception { + + Map badDoubleMap = new HashMap(); + badDoubleMap.put("key", "bad double"); + + try { + new JobParameters(stringMap, longMap, badDoubleMap, dateMap); fail(); } catch (IllegalArgumentException ex) { @@ -85,7 +105,7 @@ public class JobParametersTests extends TestCase { badMap.put("key", new Integer(2)); try { - new JobParameters(badMap, longMap, dateMap); + new JobParameters(badMap, longMap, doubleMap, dateMap); fail(); } catch (IllegalArgumentException ex) { @@ -99,7 +119,7 @@ public class JobParametersTests extends TestCase { badMap.put("key", new java.sql.Date(System.currentTimeMillis())); try { - new JobParameters(stringMap, longMap, badMap); + new JobParameters(stringMap, longMap, doubleMap, badMap); fail(); } catch (IllegalArgumentException ex) { @@ -126,6 +146,16 @@ public class JobParametersTests extends TestCase { assertEquals(new Long(1), parameters.getLongParameters().get("long.key1")); assertEquals(new Long(2), parameters.getLongParameters().get("long.key2")); } + + public void testGetDouble() { + assertEquals(new Double(1.1), parameters.getDouble("double.key1")); + assertEquals(new Double(2.2), parameters.getDouble("double.key2")); + } + + public void testGetDoubleParameters() { + assertEquals(new Double(1.1), parameters.getDoubleParameters().get("double.key1")); + assertEquals(new Double(2.2), parameters.getDoubleParameters().get("double.key2")); + } public void testGetDate() { assertEquals(date1, parameters.getDate("date.key1")); @@ -184,12 +214,16 @@ public class JobParametersTests extends TestCase { longMap = new HashMap(); longMap.put("long.key2", new Long(2)); longMap.put("long.key1", new Long(1)); + + doubleMap = new HashMap(); + doubleMap.put("double.key2", new Double(2.2)); + doubleMap.put("double.key1", new Double(1.1)); dateMap = new HashMap(); dateMap.put("date.key2", date2); dateMap.put("date.key1", date1); - JobParameters testProps = new JobParameters(stringMap, longMap, dateMap); + JobParameters testProps = new JobParameters(stringMap, longMap, doubleMap, dateMap); props = testProps.getParameters(); stringBuilder = new StringBuilder(); diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcJobInstanceDao.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcJobInstanceDao.java index b73e7211a..4fef13593 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcJobInstanceDao.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcJobInstanceDao.java @@ -32,11 +32,11 @@ import org.springframework.util.Assert; */ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements JobInstanceDao, InitializingBean { - private static final String CREATE_JOB = "INSERT into %PREFIX%JOB_INSTANCE(JOB_INSTANCE_ID, JOB_NAME, JOB_KEY)" + private static final String CREATE_JOB_INSTANCE = "INSERT into %PREFIX%JOB_INSTANCE(JOB_INSTANCE_ID, JOB_NAME, JOB_KEY)" + " values (?, ?, ?)"; private static final String CREATE_JOB_PARAMETERS = "INSERT into %PREFIX%JOB_PARAMS(JOB_INSTANCE_ID, KEY_NAME, TYPE_CD, " - + "STRING_VAL, DATE_VAL, LONG_VAL) values (?, ?, ?, ?, ?, ?)"; + + "STRING_VAL, DATE_VAL, LONG_VAL, DOUBLE_VAL) values (?, ?, ?, ?, ?, ?, ?)"; private static final String FIND_JOBS = "SELECT JOB_INSTANCE_ID from %PREFIX%JOB_INSTANCE where JOB_NAME = ? and JOB_KEY = ?"; @@ -59,7 +59,7 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements Long jobId = new Long(jobIncrementer.nextLongValue()); Object[] parameters = new Object[] { jobId, job.getName(), createJobKey(jobParameters) }; - getJdbcTemplate().update(getQuery(CREATE_JOB), parameters, + getJdbcTemplate().update(getQuery(CREATE_JOB_INSTANCE), parameters, new int[] { Types.INTEGER, Types.VARCHAR, Types.VARCHAR }); insertJobParameters(jobId, jobParameters); @@ -104,6 +104,15 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements insertParameter(jobId, ParameterType.LONG, entry.getKey().toString(), entry.getValue()); } } + + parameters = jobParameters.getDoubleParameters(); + + if (!parameters.isEmpty()) { + for (Iterator it = parameters.entrySet().iterator(); it.hasNext();) { + Entry entry = (Entry) it.next(); + insertParameter(jobId, ParameterType.DOUBLE, entry.getKey().toString(), entry.getValue()); + } + } parameters = jobParameters.getDateParameters(); @@ -123,16 +132,19 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements Object[] args = new Object[0]; int[] argTypes = new int[] { Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP, - Types.INTEGER }; + Types.INTEGER, Types.DOUBLE }; if (type == ParameterType.STRING) { - args = new Object[] { jobId, key, type, value, new Timestamp(0L), new Long(0) }; + args = new Object[] { jobId, key, type, value, new Timestamp(0L), new Long(0), new Double(0) }; } else if (type == ParameterType.LONG) { - args = new Object[] { jobId, key, type, "", new Timestamp(0L), value }; + args = new Object[] { jobId, key, type, "", new Timestamp(0L), value, new Double(0) }; + } + else if (type == ParameterType.DOUBLE) { + args = new Object[] { jobId, key, type, "", new Timestamp(0L), new Long(0), value }; } else if (type == ParameterType.DATE) { - args = new Object[] { jobId, key, type, "", value, new Long(0) }; + args = new Object[] { jobId, key, type, "", value, new Long(0), new Double(0) }; } getJdbcTemplate().update(getQuery(CREATE_JOB_PARAMETERS), args, argTypes); @@ -196,8 +208,10 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements public static final ParameterType DATE = new ParameterType("DATE"); public static final ParameterType LONG = new ParameterType("LONG"); + + public static final ParameterType DOUBLE = new ParameterType("DOUBLE"); - private static final ParameterType[] VALUES = { STRING, DATE, LONG }; + private static final ParameterType[] VALUES = { STRING, DATE, LONG, DOUBLE }; public static ParameterType getType(String typeAsString) { diff --git a/spring-batch-execution/src/main/resources/schema-db2.sql b/spring-batch-execution/src/main/resources/schema-db2.sql index 37f25363e..20037043d 100644 --- a/spring-batch-execution/src/main/resources/schema-db2.sql +++ b/spring-batch-execution/src/main/resources/schema-db2.sql @@ -33,7 +33,8 @@ CREATE TABLE BATCH_JOB_PARAMS ( KEY_NAME VARCHAR(100) NOT NULL , STRING_VAL VARCHAR(250) , DATE_VAL TIMESTAMP , - LONG_VAL BIGINT ); + LONG_VAL BIGINT , + DOUBLE_VAL DOUBLE PRECISION); CREATE TABLE BATCH_STEP_EXECUTION ( STEP_EXECUTION_ID BIGINT PRIMARY KEY , diff --git a/spring-batch-execution/src/main/resources/schema-derby.sql b/spring-batch-execution/src/main/resources/schema-derby.sql index 6304572eb..4f259ffb8 100644 --- a/spring-batch-execution/src/main/resources/schema-derby.sql +++ b/spring-batch-execution/src/main/resources/schema-derby.sql @@ -33,7 +33,8 @@ CREATE TABLE BATCH_JOB_PARAMS ( KEY_NAME VARCHAR(100) NOT NULL , STRING_VAL VARCHAR(250) , DATE_VAL TIMESTAMP , - LONG_VAL BIGINT ); + LONG_VAL BIGINT , + DOUBLE_VAL DOUBLE PRECISION); CREATE TABLE BATCH_STEP_EXECUTION ( STEP_EXECUTION_ID BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, diff --git a/spring-batch-execution/src/main/resources/schema-hsqldb.sql b/spring-batch-execution/src/main/resources/schema-hsqldb.sql index fdf777822..7b3249773 100644 --- a/spring-batch-execution/src/main/resources/schema-hsqldb.sql +++ b/spring-batch-execution/src/main/resources/schema-hsqldb.sql @@ -33,7 +33,8 @@ CREATE TABLE BATCH_JOB_PARAMS ( KEY_NAME VARCHAR(100) NOT NULL , STRING_VAL VARCHAR(250) , DATE_VAL TIMESTAMP , - LONG_VAL BIGINT ); + LONG_VAL BIGINT , + DOUBLE_VAL DOUBLE PRECISION); CREATE TABLE BATCH_STEP_EXECUTION ( STEP_EXECUTION_ID BIGINT IDENTITY PRIMARY KEY , diff --git a/spring-batch-execution/src/main/resources/schema-mysql.sql b/spring-batch-execution/src/main/resources/schema-mysql.sql index 71f460e86..b178b7236 100644 --- a/spring-batch-execution/src/main/resources/schema-mysql.sql +++ b/spring-batch-execution/src/main/resources/schema-mysql.sql @@ -33,7 +33,8 @@ CREATE TABLE BATCH_JOB_PARAMS ( KEY_NAME VARCHAR(100) NOT NULL , STRING_VAL VARCHAR(250) , DATE_VAL TIMESTAMP , - LONG_VAL BIGINT ); + LONG_VAL BIGINT , + DOUBLE_VAL DOUBLE PRECISION); CREATE TABLE BATCH_STEP_EXECUTION ( STEP_EXECUTION_ID BIGINT unsigned PRIMARY KEY , diff --git a/spring-batch-execution/src/main/resources/schema-oracle10g.sql b/spring-batch-execution/src/main/resources/schema-oracle10g.sql index 0216a0253..5dc69616e 100644 --- a/spring-batch-execution/src/main/resources/schema-oracle10g.sql +++ b/spring-batch-execution/src/main/resources/schema-oracle10g.sql @@ -33,7 +33,8 @@ CREATE TABLE BATCH_JOB_PARAMS ( KEY_NAME VARCHAR(100) NOT NULL , STRING_VAL VARCHAR(250) , DATE_VAL TIMESTAMP , - LONG_VAL NUMBER(38) ); + LONG_VAL NUMBER(38) , + DOUBLE_VAL DOUBLE PRECISION); CREATE TABLE BATCH_STEP_EXECUTION ( STEP_EXECUTION_ID NUMBER(38) PRIMARY KEY , diff --git a/spring-batch-execution/src/main/resources/schema-postgresql.sql b/spring-batch-execution/src/main/resources/schema-postgresql.sql index 37f25363e..20037043d 100644 --- a/spring-batch-execution/src/main/resources/schema-postgresql.sql +++ b/spring-batch-execution/src/main/resources/schema-postgresql.sql @@ -33,7 +33,8 @@ CREATE TABLE BATCH_JOB_PARAMS ( KEY_NAME VARCHAR(100) NOT NULL , STRING_VAL VARCHAR(250) , DATE_VAL TIMESTAMP , - LONG_VAL BIGINT ); + LONG_VAL BIGINT , + DOUBLE_VAL DOUBLE PRECISION); CREATE TABLE BATCH_STEP_EXECUTION ( STEP_EXECUTION_ID BIGINT PRIMARY KEY , diff --git a/spring-batch-execution/src/main/sql/init.sql.vpp b/spring-batch-execution/src/main/sql/init.sql.vpp index cc40c5c05..34490f15b 100644 --- a/spring-batch-execution/src/main/sql/init.sql.vpp +++ b/spring-batch-execution/src/main/sql/init.sql.vpp @@ -22,7 +22,8 @@ CREATE TABLE BATCH_JOB_PARAMS ( KEY_NAME VARCHAR(100) NOT NULL , STRING_VAL VARCHAR(250) , DATE_VAL TIMESTAMP , - LONG_VAL ${BIGINT} ); + LONG_VAL ${BIGINT} , + DOUBLE_VAL ${DOUBLE}); CREATE TABLE BATCH_STEP_EXECUTION ( STEP_EXECUTION_ID ${BIGINT} $!{IDENTITY} PRIMARY KEY $!{GENERATED}, diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryIntegrationTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryIntegrationTests.java index 0bbdf803e..263758c93 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryIntegrationTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryIntegrationTests.java @@ -46,12 +46,17 @@ public class SimpleJobRepositoryIntegrationTests extends AbstractTransactionalDa put("longKey", new Long(1)); } }; + Map doubleParams = new HashMap() { + { + put("doubleKey", new Double(1.1)); + } + }; Map dateParams = new HashMap() { { put("dateKey", new Date(1)); } }; - JobParameters jobParams = new JobParameters(stringParams, longParams, dateParams); + JobParameters jobParams = new JobParameters(stringParams, longParams, doubleParams, dateParams); JobExecution firstExecution = jobRepository.createJobExecution(job, jobParams); firstExecution.setStartTime(new Date()); diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractJobDaoTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractJobDaoTests.java index dbbf9b849..14483b0b1 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractJobDaoTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractJobDaoTests.java @@ -42,8 +42,8 @@ public abstract class AbstractJobDaoTests extends AbstractTransactionalDataSourc protected JobExecutionDao jobExecutionDao; - protected JobParameters jobParameters = new JobParametersBuilder().addString("job.key", "jobKey"). - addLong("long", new Long(1)).addDate("date", new Date(7)).toJobParameters(); + protected JobParameters jobParameters = new JobParametersBuilder().addString("job.key", "jobKey").addLong("long", + new Long(1)).addDate("date", new Date(7)).addDouble("double", new Double(7.7)).toJobParameters(); protected JobInstance jobInstance; @@ -226,7 +226,7 @@ public abstract class AbstractJobDaoTests extends AbstractTransactionalDataSourc } public void testJobWithDefaultJobIdentifier() throws Exception { - + Job testDefaultJob = new JobSupport("testDefault"); // Create job. jobInstance = jobInstanceDao.createJobInstance(testDefaultJob, jobParameters); diff --git a/spring-batch-execution/src/test/resources/org/springframework/batch/execution/repository/dao/init.sql b/spring-batch-execution/src/test/resources/org/springframework/batch/execution/repository/dao/init.sql index a03135b35..7101a15dc 100644 --- a/spring-batch-execution/src/test/resources/org/springframework/batch/execution/repository/dao/init.sql +++ b/spring-batch-execution/src/test/resources/org/springframework/batch/execution/repository/dao/init.sql @@ -22,7 +22,8 @@ CREATE TABLE BATCH_JOB_PARAMS ( KEY_NAME VARCHAR(100) NOT NULL , STRING_VAL VARCHAR(250) , DATE_VAL TIMESTAMP , - LONG_VAL BIGINT ); + LONG_VAL BIGINT , + DOUBLE_VAL DOUBLE PRECISION); CREATE TABLE BATCH_STEP_EXECUTION ( STEP_EXECUTION_ID BIGINT IDENTITY PRIMARY KEY ,