euraad
euraad

Reputation: 2856

If DB connection got lost, will JPA save the saved data later?

I would like to know if Spring JPA will save the data later if the DB connection got lost and then the connection with DB works again.

Assume that we have a myService with the method save(MyEtinty myEntity).

And then I call this method every second.

myService.save(myEntity);

And suddenly the DB connection lost due to the WiFi is ubstable. But efter 10 minutes it works again.

Will JPA buffer the data and then load it into the database after it has restablish the connection?

Upvotes: 0

Views: 190

Answers (1)

Matheus
Matheus

Reputation: 3390

No, there's no such buffer implemented. You'll have to do it manually, if needed.

If you're using Spring Data JPA repositories, the CrudRepository#save method only checks if the object already exists on the database and then call EntityManager#save or EntityManager#merge.

Upvotes: 1

Related Questions