XmlTransaction
objects are actually wrappers
around Berkeley DB
DB_TXN
objects. It is
therefore possible for you to use both XmlTransaction
and
DB_TXN
handles for the same transaction simultaneously.
(DB_TXN
objects are what Berkeley DB use to manage transactions. See the
Berkeley DB C++
version of this guide for details on their usage.)
This is interesting if you want to write an application that makes use of both Berkeley DB databases and Berkeley DB XML containers. Because BDB XML uses Berkeley DB for storage and transactions, all of the Berkeley DB APIs are available to your BDB XML application.
To obtain the underlying
DB_TXN
object from an
XmlTransaction
object, use
XmlTransaction::getDB_TXN()
.
You can also create an XmlTransaction
object
around an existing
DB_TXN
object by passing that object to
XmlManager::createTransaction()
.
When you use both BDB XML and Berkeley DB transaction handles for the same transaction simultaneously, there are a few things you need to keep in mind:
Any handle for a transaction object can commit or abort that transaction. Once committed or aborted, all handles to the transaction are no longer valid.
If the XmlTransaction
object goes out
of scope without being committed or aborted, then the
external
DB_TXN
object that was used to create it is still valid and the underlying
transaction is still active (until such a time as the
transaction is either committed or aborted in some other
location in your code).
If the parent
DB_TXN
object goes out scope while the
XmlTransaction
object is still active, then the underlying transaction
is still active until such a time as the
XmlTransaction
object calls either commit or abort.
If all XmlTransaction
objects go
out of scope and there are no in-scope
DB_TXN
objects, then the underlying transaction is
automatically aborted.