79334380

Date: 2025-01-06 21:31:02
Score: 2
Natty:
Report link

I believe the save(...) method is marked with @Transactional meaning that a transaction is started and committed each time the save method is called in the for loop.

I'd first start by following the advice in this blog to enable SQL logging (which will you better understand the SQL that is generated by JPA).

Then I'd follow the bulk insert advice in this StackOverflow post and see if you get better performance.

Lastly, if you're going to be using JPA for persistence, I can't recommend Vlad Mihalcea's blog enough. You'll find a TON of valuable insights.

Reasons:
  • Blacklisted phrase (1): this blog
  • Blacklisted phrase (1): StackOverflow
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: wmkoch