title: How to delete a list of entities
body: <p>I have a JPA query to delete selected entities which is stored in a list. I am currently deleting the entities in a loop via the in built JPA delete() method 1 by 1. Is there a way to just pass in the list instead of looping it? </p>
  
  <p>Current implementation that works but looping to delete 1 by 1. I need the initial query to get list of entities for other reasons thus not looking to change that. Just a way to pass in the list of entiies to be deleted. Please advice. Thanks. </p>
  
  <p>Note: This is with Java 8 and Spring 4.3 if it matters. </p>
  
  <pre><code>@GetMapping("/delete/{name}/{count}")
  public String delete(@PathVariable String name, @PathVariable int count){
      boolean isDelete = true;
      while (isDelete){
          //1st query
          List&lt;PersonEntity&gt; results = personService.get(name, count);
          if(results != null &amp;&amp; !results.isEmpty()){
              System.out.println("Deleting following: ");
              //2nd query
              results.forEach(p -&gt; {
                  System.out.println(p.getName());
                  personService.delete(p);
              });
          } else {
              isDelete = false;
          }
      }
      return "Done!";
  }
  </code></pre>