问题
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