title: Spring batch how to run a job in loop until it meets a condition?
body: <pre><code>&lt;job id="firstJob" restartable="true"
      xmlns="http://www.springframework.org/schema/batch"&gt;
      &lt;step id="FirstStep"&gt;
          &lt;tasklet&gt;
              &lt;chunk reader="read" writer="write"
                  commit-interval="1" /&gt;
          &lt;/tasklet&gt;
      &lt;/step&gt;
  &lt;/job&gt;
  
  
  
  &lt;job id="second_job" restartable="false"
      xmlns="http://www.springframework.org/schema/batch"&gt;
      &lt;step id="second_step" "&gt;
          &lt;tasklet&gt;
              &lt;chunk reader="reader_again" writer="writera_gain"
                  commit-interval="500" /&gt;
          &lt;/tasklet&gt;      
  &lt;/job&gt;
  </code></pre>
  
  <p>I have two jobs here (3 in my actualcode). I want to run  the first job to check for some value inthe database and only execute once it finds that value. For this I want it to keep looping until it can find the data and then continue. How can I do this through Spring Batch xml? Is there a better way to do this?</p>
  
  <p>Also, I can't change the structure i.e make two jobs into two steps due to the size of the codebase. </p>