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

Variable Index

 o READ
Read lock on an object.
 o UPGRADE
Upgrade lock on an object when upgrading from a read lock to a write lock.
 o WRITE
Write lock on an object.

Constructor Index

 o Transaction()
Instantiates a transaction on the current host, but does not start it yet.

Method Index

 o abort()
Aborts the transaction and undoes any changes to the database that were made during the transaction.
 o begin()
Starts this transaction.
 o checkpoint()
Commits the transaction and reopens it without retaining locks.
 o commit()
Commits a transaction.
 o current()
Obtains the transaction associated with this thread.
 o isOpen()
Indicates whether or not this transaction is in progress.
 o join()
Joins this transaction to the current thread.
 o leave()
Detaches this transaction from the current thread.
 o lock(Object, int)
Locks an object with the specified mode.

Variables

 o READ
  public final static int READ
Read lock on an object.

 o UPGRADE
  public final static int UPGRADE
Upgrade lock on an object when upgrading from a read lock to a write lock.

 o WRITE
  public final static int WRITE
Write lock on an object.

Constructors

 o 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.

Methods

 o join
  public void join()
Joins this transaction to the current thread.

 o leave
  public void leave()
Detaches this transaction from the current thread. Does not attach another transaction to this thread.

 o 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.
 o 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
 o 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.
 o 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
 o 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
 o 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.
 o 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.