Spring Batch and JPA performance issue

有些话、适合烂在心里 提交于 2020-06-27 05:28:09

问题


Before posting the question, I went through many links over web like below and I'm facing drastic performance issue when trying to perform JPA saveAll(entity) when loading data into target DB using Spring boot and Spring Batch.

Spring Boot JPA saveAll() inserting to database extremely slowly

Spring Boot JPARepository performance on save()

https://vladmihalcea.com/the-best-way-to-do-batch-processing-with-jpa-and-hibernate/

https://dzone.com/articles/50-best-performance-practices-for-hibernate-5-amp

I'm using JPA to write data into target system however using Spring JDBC to read data. Just to insert 20K records into database its taking almost 4 hour.

@Override
public void write(List<? extends DepartmentDto> departmentDtoList) throws Exception {
     .......
     .........
     ..........
     ..........
     // some mapping using Java 8 and assume entities are derived by making API calls to other systems.

     employeeRepository.saveAll(employees);
     departmentRepository.saveAll(departments);
}

来源:https://stackoverflow.com/questions/62393378/spring-batch-and-jpa-performance-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!