in my Java web application, I would like to persist every 100 instances of the save entity at once, what is the best way to do that? I have some time constraints that I have to respect, the persisting operation should be fast. I there any method faster than the others? Thank you
Share
Basically what you are looking for is batch insert into database using JPA. These topics have already been brought up, these will help you:
Summary
Using Hibernate’s batch inserts. Hiberate provides methods for batch inserting and updating entities.
Disabling automatic ID generation.
If you generate ids automatically, Hibernate executes query for each entity to generate the primary key.
Opinion
Basically I think that disabling automatic ID generation is a bad idea. You can take most of Hibernate’s batch methods, but this will not save you much of performance.
After this is done, I suggest you looking for optimizations in other layers of your application.