Debian Codegraph @

docs/gsg_txn/JAVA/nestedtxn.html

raw
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <title>Nested Transactions</title>
7 <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
9 <link rel="start" href="index.html" title="Getting Started with Berkeley DB Transaction Processing" />
10 <link rel="up" href="usingtxns.html" title="Chapter 3. Transaction Basics" />
11 <link rel="prev" href="autocommit.html" title="Auto Commit" />
12 <link rel="next" href="txncursor.html" title="Transactional Cursors" />
13 </head>
14 <body>
15 <div xmlns="" class="navheader">
16 <div class="libver">
17 <p>Library Version 11.2.5.3</p>
18 </div>
19 <table width="100%" summary="Navigation header">
20 <tr>
21 <th colspan="3" align="center">Nested Transactions</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="autocommit.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 3. Transaction Basics</th>
26 <td width="20%" align="right"> <a accesskey="n" href="txncursor.html">Next</a></td>
27 </tr>
28 </table>
29 <hr />
30 </div>
31 <div class="sect1" lang="en" xml:lang="en">
32 <div class="titlepage">
33 <div>
34 <div>
35 <h2 class="title" style="clear: both"><a id="nestedtxn"></a>Nested Transactions</h2>
36 </div>
37 </div>
38 </div>
39 <p>
40 A <span class="emphasis"><em>nested transaction</em></span> is used to provide a
41 transactional guarantee for a subset of operations performed within
42 the scope of a larger transaction. Doing this allows you to commit
43 and abort the subset of operations independently of the larger
44 transaction.
45 </p>
46 <p>
47 The rules to the usage of a nested transaction are as follows:
48 </p>
49 <div class="itemizedlist">
50 <ul type="disc">
51 <li>
52 <p>
53 While the nested (child) transaction is active, the parent
54 transaction may not perform any operations other than to commit
55 or abort, or to create more child transactions.
56 </p>
57 </li>
58 <li>
59 <p>
60 Committing a nested transaction has no effect on the state
61 of the parent transaction. The parent transaction is still
62 uncommitted. However, the parent transaction can now
63 see any modifications made by the child transaction.
64 Those modifications, of course, are still hidden to all
65 other transactions until the parent also commits.
66 </p>
67 </li>
68 <li>
69 <p>
70 Likewise, aborting the nested transaction has no effect on
71 the state of the parent transaction. The only result of the
72 abort is that neither the parent nor any
73 other transactions will see any of the
74 database modifications performed under the protection of the
75 nested transaction.
76 </p>
77 </li>
78 <li>
79 <p>
80 If the parent transaction commits or aborts while it has
81 active children, the child transactions are resolved in the
82 same way as the parent. That is, if the parent aborts, then
83 the child transactions abort as well. If the parent commits,
84 then whatever modifications have been performed by the child
85 transactions are also committed.
86 </p>
87 </li>
88 <li>
89 <p>
90 The locks held by a nested transaction are not released when
91 that transaction commits. Rather, they are now held by the
92 parent transaction until such a time as that parent commits.
93 </p>
94 </li>
95 <li>
96 <p>
97 Any database modifications performed by the nested transaction
98 are not visible outside of the larger encompassing
99 transaction until such a time as that parent transaction is
100 committed.
101 </p>
102 </li>
103 <li>
104 <p>
105 The depth of the nesting that you can achieve with nested
106 transaction is limited only by memory.
107 </p>
108 </li>
109 </ul>
110 </div>
111 <p>
112 To create a nested transaction, simply pass the parent transaction's
113 handle when you created the nested transaction's handle. For
114 example:
115 </p>
116 <pre class="programlisting"> // parent transaction
117 Transaction parentTxn = myEnv.beginTransaction(null, null);
118 // child transaction
119 Transaction childTxn = myEnv.beginTransaction(parentTxn, null); </pre>
120 </div>
121 <div class="navfooter">
122 <hr />
123 <table width="100%" summary="Navigation footer">
124 <tr>
125 <td width="40%" align="left"><a accesskey="p" href="autocommit.html">Prev</a> </td>
126 <td width="20%" align="center">
127 <a accesskey="u" href="usingtxns.html">Up</a>
128 </td>
129 <td width="40%" align="right"> <a accesskey="n" href="txncursor.html">Next</a></td>
130 </tr>
131 <tr>
132 <td width="40%" align="left" valign="top">Auto Commit </td>
133 <td width="20%" align="center">
134 <a accesskey="h" href="index.html">Home</a>
135 </td>
136 <td width="40%" align="right" valign="top"> Transactional Cursors</td>
137 </tr>
138 </table>
139 </div>
140 </body>
141 </html>