DefaultJpaRepository extends CrudRepositorySupport { public Iterable deleteAllInBatch() { log.info("Attempting to delete all the entities in the data store in a batch"); return deleteByKeysInBatch(getDataStore().keys()); }  void flush(); Iterable deleteInBatch(Iterable entities); Iterable deleteAllInBatch(); Object getOne(Object key); Object saveAndFlush(Object entity);  }
@Test public void testDeleteAllInBatch() { dataStore.save("1", new Person()); dataStore.save("2", new Person()); dataStore.save("3", new Person()); dataStore.save("4", new Person()); assertThat(dataStore.keys(), hasSize(4)); repository.deleteAllInBatch(); assertThat(dataStore.keys(), is(empty())); }
@Test public void testDeleteInBatchWithQueueing() { final SpyingDataStore<String, Person> dataStore = new SpyingDataStore<>( new MemoryDataStore<>(Person.class), new AtomicLong()); dataStore.save("1", new Person()); dataStore.save("2", new Person()); dataStore.save("3", new Person()); dataStore.save("4", new Person()); repository.setDataStore(dataStore); assertThat(dataStore.keys(), hasSize(4)); repository.deleteAllInBatch(); assertThat(dataStore.keys(), is(empty())); }