@Override
public void contextInitialized(ServletContextEvent sce) {
LOGGER.debug("initializing..");
WebApplicationContext ctx = WebApplicationContextUtils
.getWebApplicationContext(sce.getServletContext());
PersonRepository personRepository = ctx.getBean(PersonRepository.class);
personRepository.deleteAll();
List<Person> persons = new ArrayList<Person>();
int itemCount = 100;
int chunkSize = 25;
for (int i = 1; i <= itemCount; i++) {
Person p = new Person();
p.setAge((i % 100) + 1);
p.setName("name" + i);
persons.add(p);
if ((i % chunkSize) == 0) {
personRepository.save(persons);
persons.clear();
}
}
personRepository.save(persons);
}