Java Reference
In-Depth Information
Table 7.3
Failed deposit
Alice's account
Bob's account
Balance
$5,000.00
Balance
$10,000.00
Withdrawal
$1,000.00
Deposit (FAILS)
$1,000.00
Balance
$4,000.00
Balance
$10,000.00
A transaction would ensure that if the deposit failed, the withdrawal would be
rolled back. After the rollback, the data would be in the same state it was before
the transaction began (table 7.4).
Table 7.4
Failed deposit
Alice's account
TX
Bob's account
Balance
$5,000.00
Balance
$10,000.00
Withdrawal (Rollback)
$1,000.00
TX1
TX1
Deposit (FAILS)
$1,000.00
Balance
$5,000.00
Balance
$10,000.00
This is quite a simple example. As you can imagine, a true-life transfer of funds
within a banking system would be much more complex. For that reason, there
are various types of transactions that allow transactions to encompass a much
broader scope.
Transactions can be very small and basic, perhaps consisting of only a couple
of SQL statements that change data in a single table of a single database. How-
ever, transactions can also become very large and complex. A business-to-business
transaction could even leave the realm of computers and require physical inter-
action with human beings (e.g., a signature). The topic of transactions could eas-
ily fill a topic of its own, so we'll only consider four scopes of transactions that
i BATIS supports:
Automatic —For simple, single statements that don't require an explicitly
demarcated transaction.
Local —A simple, narrowly scoped transaction involving many statements
but only a single database.
Search WWH ::




Custom Search