Class COM.odi.odmg.Transaction
java.lang.Object
|
+----COM.odi.odmg.Transaction
- public final class Transaction
- extends Object
The way that ODMG uses a transaction is similar to the way that ObjectStore
uses a transaction. There are
methods for beginning, committing, and aborting the transaction.
In addition, there are methods for joining the current ODMG transaction
to the current thread, and detaching the current thread from this
transaction. With these methods, ODMG transactions are like
ObjectStore sessions. An ODMG transaction can be associated with
several threads and
multiple open databases.
However, ODMG transactions are different from ObjectStore
transactions in that you can start and commit or abort the same
ODMG transaction multiple times.
- See Also:
- Transaction
-
READ
- Read lock on an object.
-
UPGRADE
- Upgrade lock on an object when upgrading from a read
lock to a write lock.
-
WRITE
- Write lock on an object.
-
Transaction()
- Instantiates a transaction on the current host, but does not start it yet.
-
abort()
- Aborts the transaction and undoes any changes to the database
that were made during the transaction.
-
begin()
- Starts this transaction.
-
checkpoint()
- Commits the transaction and reopens it without retaining locks.
-
commit()
- Commits a transaction.
-
current()
- Obtains the transaction associated with this thread.
-
isOpen()
- Indicates whether or not this transaction is in progress.
-
join()
- Joins this transaction to the current thread.
-
leave()
- Detaches this transaction from the current thread.
-
lock(Object, int)
- Locks an object with the specified mode.
READ
public final static int READ
- Read lock on an object.
UPGRADE
public final static int UPGRADE
- Upgrade lock on an object when upgrading from a read
lock to a write lock.
WRITE
public final static int WRITE
- Write lock on an object.
Transaction
public Transaction()
- Instantiates a transaction on the current host, but does not start it yet.
A call to Transaction.begin() starts the transaction.
An application can start and commit or abort the same instance of
an ODMG transaction multiple times.
This public constructor is necessary to conform with the ODMG API.
The current thread is associated with this transaction.
Instantiation of a new transaction associates the current thread
with the new instance of Transaction.
join
public void join()
- Joins this transaction to the current thread.
leave
public void leave()
- Detaches this transaction from the current thread.
Does not attach another transaction to this thread.
current
public static Transaction current()
- Obtains the transaction associated with this thread.
- Returns:
- The transaction associated with this thread. If there
is no transaction associated with the current thread, returns null.
begin
public void begin()
- Starts this transaction.
- Throws: ObjectStoreException
- If this transaction is not
associated with any threads.
- Throws: TransactionInProgressException
- If this
transaction has already been started.
- See Also:
- begin
isOpen
public boolean isOpen()
- Indicates whether or not this transaction is in progress.
A call to Transaction.begin() starts the transaction.
- Returns:
- Returns true if this transaction is in progress, and false otherwise.
commit
public void commit()
- Commits a transaction.
- Throws: ObjectNotPersistenceCapableException
- If ObjectStore
reaches an object while it is performing transitive persistence and
that object is not persistence-capable.
- Throws: ObjectStoreException
- If there are no threads
associated with this transaction.
- Throws: TransactionNotInProgressException
- If this
transaction is not in progress.
- See Also:
- commit
abort
public void abort()
- Aborts the transaction and undoes any changes to the database
that were made during the transaction.
- Throws: ObjectStoreException
- If there are no threads
associated with this transaction.
- Throws: TransactionNotInProgressException
- If this
transaction is not in progress.
- See Also:
- abort
checkpoint
public void checkpoint()
- Commits the transaction and reopens it without retaining locks.
The ODMG Transaction.checkpoint() method retains locks from the
committed transaction and reopens the transaction with the retained locks.
- Throws: ObjectNotPersistenceCapableException
- If ObjectStore
reaches an object while it is performing transitive persistence and
that object is not persistence-capable.
- Throws: ObjectStoreException
- If there are no threads
associated with this transaction.
- Throws: TransactionNotInProgressException
- If this
transaction is not in progress.
lock
public void lock(Object obj,
int mode)
- Locks an object with the specified mode.
Currently, the UPGRADE mode does not have any meaning.
- Parameters:
- obj - The object to lock with the specified mode.
- mode - The mode for locking this object, either READ or WRITE.
- Throws: DatabaseNotFoundException
- If the object was
accessed through a cross-database reference to a database that is not
found.
- Throws: DatabaseClosedException
- If the database that contains
the object is not open.
- Throws: ObjectException
- If the object being locked is a stale
object.
- Throws: ObjectNotFoundException
- If the object was destroyed,
or its segment was destroyed.
- Throws: ObjectNotPersistenceCapableException
- If the object is
not persistence-capable.
- Throws: TransactionNotInProgressException
- If this
transaction is not in progress.
Copyright © 1996, 1997, 1998 Object Design, Inc. All rights reserved.