public JobInstance createJobInstance(String jobName,
JobParameters jobParameters) {
Assert.notNull(jobName, "Job name must not be null.");
Assert.notNull(jobParameters, "JobParameters must not be null.");
Assert.state(getJobInstance(jobName, jobParameters) == null,
"JobInstance must not already exist");
Long jobId = jobIncrementer.nextLongValue();
JobInstance jobInstance = new JobInstance(jobId, jobParameters, jobName);
jobInstance.incrementVersion();
Object[] parameters = new Object[] { jobId, jobName,
createJobKey(jobParameters), jobInstance.getVersion() };
getJdbcTemplate().getJdbcOperations().update(
getQuery(CREATE_JOB_INSTANCE),
parameters,
new int[] { Types.BIGINT, Types.VARCHAR, Types.VARCHAR,
Types.INTEGER });
insertJobParameters(jobId, jobParameters);
return jobInstance;
}