title: Spring batch A job instance already exists
body: <p>OK,</p>
  
  <p>I know this has been asked before, but I still can't find a definite answer to my question. And my question is this: I am using spring batch to export data to SOLR search server. It needs to run every minute, so I can export all the updates. The first execution passes OK, but the second one complains with:</p>
  
  <pre><code>2014-10-02 20:37:00,022 [defaultTaskScheduler-1] ERROR: catching
  org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException: A job     instance already exists and is complete for parameters={catalogVersionPK=3378876823725152,
  type=UPDATE}.  If you want to run this job again, change the parameters.
      at org.springframework.batch.core.repository.support.SimpleJobRepository.createJobExecution(SimpleJobRepository.java:126)
      at 
  </code></pre>
  
  <p>Of course I can add a date-time parameter to the job like this:</p>
  
  <pre><code>.addLong("time", System.getCurrentTimeMillis())
  </code></pre>
  
  <p>and then the job can be run more than once. However, I also want to query the last execution of the job, so I have code like this:</p>
  
  <pre><code>DateTime endTime = new DateTime(0);
  JobExecution je = jobRepository.getLastJobExecution("searchExportJob", new JobParametersBuilder().addLong("catalogVersionPK", catalogVersionPK).addString("type", type).toJobParameters());
  if (je != null &amp;&amp; je.getEndTime() != null) {
     endTime = new DateTime(je.getEndTime());
  }
  </code></pre>
  
  <p>and this returns nothing, because I didn't provide the time parameter. So seems like I can run the job once and get the last execution time, or i can run it multiple times and not get the last execution time. I am really stuck :(</p>