I'm using spring-data-jpa 1.x in my project and there is a bulk-insert scenario like:
List<Entity> entities = ...;
entities.forEach(repository::save);
But I have millions of entities to insert and it takes too long time due to database connection latency. I need something like:
repository.saveAll(entities);
to speed up my insertion.
Up to spring-data-jpa:1.11.23.RELEASE which is the latest version of spring-data-jpa 1.x, there is still no such method like saveAll().
=== UPDATE ===
In spring-data-jpa 1.x the method name is save():
<S extends T> List<S> save(Iterable<S> entities)
=== UPDATE-2 ===
Just using save() (spring-data-jpa 1.x) or saveAll() (spring-data-jpa 2.x) can't make hibernate generate multi-insert SQL like INSERT INTO table VALUES (?, ?, ...), (?, ?, ...), .... This is another topic, see: M. Deinum and Marc Ströbel's comment, or How to do bulk (multi row) inserts with JpaRepository?