Berkeley DB Java Edition
version 1.5.1

com.sleepycat.je
Class Transaction

java.lang.Object
  |
  +--com.sleepycat.je.Transaction

public class Transaction
extends Object

An environment transaction.

To obtain a transaction with default attributes:

Transaction txn = myEnvironment.beginTransaction(null, null);
To customize the attributes of a transaction:
TransactionConfig config = new TransactionConfig();
config.setDirtyRead(true);
Transaction txn = myEnvironment.beginTransaction(null, config);


Method Summary
 void abort()
          Cause an abnormal termination of the transaction.
 void commit()
          End the transaction, synchronously committing if the database environment is configured for synchronous commit.
 void commitNoSync()
          End the transaction, not committing synchronously.
 void commitSync()
          End the transaction, committing synchronously.
 String getName()
          Get the user visible name for the transaction.
 void setLockTimeout(long timeOut)
          Configure the lock request timeout value for the transaction.
 void setName(String name)
          Set the user visible name for the transaction.
 void setTxnTimeout(long timeOut)
          Configure the timeout value for the transaction.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

abort

public void abort()
           throws DatabaseException
Cause an abnormal termination of the transaction.

The log is played backward, and any necessary undo operations are done. Before Transaction.abort returns, any locks held by the transaction will have been released.

In the case of nested transactions, aborting a parent transaction causes all children (unresolved or not) of the parent transaction to be aborted.

All cursors opened within the transaction must be closed before the transaction is aborted.

After Transaction.abort has been called, regardless of its return, the Transaction handle may not be accessed again.

Throws:
DatabaseException - if a failure occurs.

commit

public void commit()
            throws DatabaseException
End the transaction, synchronously committing if the database environment is configured for synchronous commit.

If the environment is configured for synchronous commit, the transaction will be committed synchronously to stable storage before the call returns; if the environment is configured for asynchronous commit, the commit will not necessarily have been committed to stable storage before the call returns.

In the case of nested transactions, if the transaction is a parent transaction, committing the parent transaction causes all unresolved children of the parent to be committed. In the case of nested transactions, if the transaction is a child transaction, its locks are not released, but are acquired by its parent. Although the commit of the child transaction will succeed, the actual resolution of the child transaction is postponed until the parent transaction is committed or aborted; that is, if its parent transaction commits, it will be committed; and if its parent transaction aborts, it will be aborted.

All cursors opened within the transaction must be closed before the transaction is committed.

After Transaction.commit has been called, regardless of its return, the Transaction handle may not be accessed again. If Transaction.commit encounters an error, the transaction and all child transactions of the transaction will have been aborted when the call returns.

Throws:
DatabaseException - if a failure occurs.

commitSync

public void commitSync()
                throws DatabaseException
End the transaction, committing synchronously.

The transaction will be committed synchronously to stable storage before the call returns.

In the case of nested transactions, if the transaction is a parent transaction, committing the parent transaction causes all unresolved children of the parent to be committed. In the case of nested transactions, if the transaction is a child transaction, its locks are not released, but are acquired by its parent. Although the commit of the child transaction will succeed, the actual resolution of the child transaction is postponed until the parent transaction is committed or aborted; that is, if its parent transaction commits, it will be committed; and if its parent transaction aborts, it will be aborted.

All cursors opened within the transaction must be closed before the transaction is committed.

After Transaction.commit has been called, regardless of its return, the Transaction handle may not be accessed again. If Transaction.commit encounters an error, the transaction and all child transactions of the transaction will have been aborted when the call returns.

Throws:
DatabaseException - if a failure occurs.

commitNoSync

public void commitNoSync()
                  throws DatabaseException
End the transaction, not committing synchronously.

The transaction will not necessarily have been committed to stable storage before the call returns.

In the case of nested transactions, if the transaction is a parent transaction, committing the parent transaction causes all unresolved children of the parent to be committed. In the case of nested transactions, if the transaction is a child transaction, its locks are not released, but are acquired by its parent. Although the commit of the child transaction will succeed, the actual resolution of the child transaction is postponed until the parent transaction is committed or aborted; that is, if its parent transaction commits, it will be committed; and if its parent transaction aborts, it will be aborted.

All cursors opened within the transaction must be closed before the transaction is committed.

After Transaction.commit has been called, regardless of its return, the Transaction handle may not be accessed again. If Transaction.commit encounters an error, the transaction and all child transactions of the transaction will have been aborted when the call returns.

Throws:
DatabaseException - if a failure occurs.

setTxnTimeout

public void setTxnTimeout(long timeOut)
                   throws DatabaseException
Configure the timeout value for the transaction.

If the transaction runs longer than this time, the transaction may may throw DeadlockException.

Parameters:
timeOut - The timeout value for the transaction, in microseconds.

Throws:
DatabaseException - if a failure occurs.

setLockTimeout

public void setLockTimeout(long timeOut)
                    throws DatabaseException
Configure the lock request timeout value for the transaction.

If a lock request cannot be granted in this time, the transaction may throw DeadlockException.

Parameters:
timeOut - The lock request timeout value for the transaction, in microseconds.

Throws:
DatabaseException - if a failure occurs.

setName

public void setName(String name)
Set the user visible name for the transaction.

Parameters:
name - The user visible name for the transaction.


getName

public String getName()
Get the user visible name for the transaction.

Returns:
The user visible name for the transaction.


Berkeley DB Java Edition
version 1.5.1

Copyright (c) 1996-2004 Sleepycat Software, Inc. - All rights reserved.