Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is real world uses of savepoint?

 
raminaa niilian
Ranch Hand
Posts: 551
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Thank you for reading my post
Can you please explain what is uses of savepoint in real world applications?
I read that savepoint can help us to shorten the rollback window, it means that we can rollback half of a transaction instead of all of it.
I can not understand why we should commit or rollback half of a transaction?
thanks
 
Jan Cumps
Bartender
Posts: 2588
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Savepoints can be used if you want finer control over your transaction than: if it fails I discard everything, and start from scratch.

It makes sense to use savepoints if you are able to correct the cause for the rollback to that savepoint in your application.

One use case could be that it's too expensive to discard and redo all the work done in a transaction:

Expedite order scenario:
- start transaction
- allocate stock (an expensive operation)
- set Savepoint stock allocated
- make truck reservation
- reservation fails
- rollback to Savepoint stock allocated
- correct truck reservation issue and retry
- commit transaction

Regards, Jan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic