Frank
Frank

Reputation: 579

Spring data jpa save huge entity list async

I have a huge entity list say having 10000 items, I want to use the crud repository to save the list async and the api will return without waiting for the save result (because the save can take long time). Is it possible to use @async annotation to do so?

Upvotes: 0

Views: 663

Answers (1)

Stephan
Stephan

Reputation: 940

Yes you can use @Async for committing to the database. However, keep in mind that the commit will then run in a separate thread with it's own transaction. You will not see any intermediate results until the commit transaction finishes.

Upvotes: 1

Related Questions