1

I am trying to insert and Update more than 5000 records using JPA (repository.save),Which is taking more time around more than 4 mins. But I want this operation in very less time.

How to make this Operation faster?

Billal Begueradj
  • 20,717
  • 43
  • 112
  • 130
Bijaya Bhaskar Swain
  • 893
  • 1
  • 11
  • 16
  • use a batch insert? see http://stackoverflow.com/a/31020939/2310289 – Scary Wombat Mar 10 '17 at 07:04
  • thanks for u r answer. let me try this. – Bijaya Bhaskar Swain Mar 10 '17 at 07:06
  • Enable [batch processing](http://docs.jboss.org/hibernate/orm/current/userguide/html_single/Hibernate_User_Guide.html#configurations-batch) in Hibernate (configure at least the first three properties) and then simple save objects in bulk with the `crudRepository.saveAll(...)` method. Hibernate will automatically issue batch insert or update command for the objects, provided the underlying database supports them. If that doesn't work, you will have to handle batches manually. Do note that auto-flush and commit should be off for either of these to work. – manish Mar 11 '17 at 03:53
  • http://docs.jboss.org/hibernate/orm/5.2/userguide/html_single/Hibernate_User_Guide.html#batch-session-batch-insert – JB Nizet Mar 12 '17 at 12:54

0 Answers0