title: How can I delete all values that have a specific column and row number?
body: <p>This code takes too long time:</p>
  <pre><code>List&lt;DataLogg&gt; selectedLogger = dataLoggRepository.findByLoggerId(loggerId.getValue());
  for(int i = firstIndex-1; i &lt; lastIndex; i++) {
      try {
          DataLogg dataLogg = selectedLogger.get(i);
          if (dataLogg != null) {
              dataLoggRepository.delete(dataLogg);
          }
      } catch(Exception e1) {}
  }
  </code></pre>
  <p>Is there any way I can avoid this for-loop, and still delete everything between <code>firstIndex-1</code> and <code>lastIndex</code> that have the column value <code>loggerId.getValue()</code>?</p>
  <p>Suggestions from the comments below:</p>
  <pre><code>List&lt;DataLogg&gt; selectedLogger = dataLoggRepository.findByLoggerId(loggerId.getValue());
  List&lt;DataLogg&gt; deleteThese = new ArrayList&lt;DataLogg&gt;();
  for(int i = firstIndex-1; i &lt; lastIndex; i++) {
      try {
          DataLogg dataLogg = selectedLogger.get(i);
          deleteThese.add(dataLogg);
      } catch(Exception e1) {}
  }
  dataLoggRepository.deleteInBatch(deleteThese);
  </code></pre>