1

I am using JSF on JAVA EE with netbeans. I read a file line by line with a buffer reader to add the data to my database. It works properly but it is very long waiting time because I have one million of lines. To add the data to my database I am using the function persist which is in the interface Entity Manager (generated). I would like to know if there would be a way to make it faster ? Using big transactions maybe?

Thanks, Best Regards.

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
PierBJX
  • 11
  • 2
  • Can you batch the inserts in groups? Batches help improve performance by much. – ernest_k Feb 03 '18 at 08:32
  • I don't think it's possible. Indeed, where the function persist is we can not modify the code. – PierBJX Feb 03 '18 at 10:38
  • Might be some useful info on batch inserts in this question: [batch-inserts-using-jpa-entitymanager](https://stackoverflow.com/questions/10584179/batch-inserts-using-jpa-entitymanager) – Nick Wilson Feb 05 '18 at 08:39
  • JPA is not the best choice to do bulk insert, but you could make a multi-thread procedure: read and write portion of file in 4/5 threads like Java Batch partitions does – fantarama Feb 07 '18 at 14:13

0 Answers0