Chapter 13. Transactions and Concurrency
Let's say a buyer logs in to the bookshop application and purchases a book. The following actions should take place in the event of purchase:
Charge the buyer the cost of the book
Reduce the stock of the book
If the charge on the credit card fails, the stock shouldn't be reduced. Also, when the book is out of stock, the buyer shouldn't be charged. That means either both actions should be successfully completed, or they should have no effect. These actions collectively are called a transaction or unit of work. In essence, transactions provide an all-or-nothing proposition.
The concept of transactions is inherited from database management systems. By definition, a transaction must be atomic, consistent, isolated, ...
Get Hibernate Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.