CurrentTransaction (Sleepycat Software, Inc. - Berkeley DB Java API)
Keywords: com.sleepycat.bdb.CurrentTransaction,CurrentTransaction class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Berkeley DB version 4.2.52
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sleepycat.bdb
Class CurrentTransaction

    java.lang.Object
      |
      +--com.sleepycat.bdb.CurrentTransaction

public class CurrentTransaction
extends Object

Provides access to the current transaction for the current thread within the context of a Berkeley DB environment. This class provides explicit transaction control beyond that provided by the `TransactionRunner` class. However, both methods of transaction control manage per-thread transactions.

Method Summary
`DbTxn` | `abortTxn()` Aborts the transaction that is active for the current thread for this environment and makes the parent transaction (if any) the current transaction.
`DbTxn` | `beginTxn()` Begins a new transaction for this environment and associates it with the current thread.
`DbTxn` | `beginTxn(boolean dirtyRead, boolean noWait)` Begins a new transaction for this environment and associates it with the current thread.
`DbTxn` | `commitTxn()` Commits the transaction that is active for the current thread for this environment and makes the parent transaction (if any) the current transaction.
`DbEnv` | `getEnv()` Returns the underlying Berkeley DB environment.
`static CurrentTransaction` | `getInstance(DbEnv env)` Gets the CurrentTransaction accessor for a specified Berkeley DB environment.
`DbTxn` | `getTxn()` Returns the transaction associated with the current thread for this environment, or null if no transaction is active.
`boolean` | `isAutoCommit()` Returns whether AUTO_COMMIT will be used for all non-cursor write operations when no transaction is active.
`boolean` | `isDirtyRead()` Returns whether dirty-read is used for the current transaction.
`boolean` | `isNoWait()` Returns whether no-wait is used for the current transaction.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### getInstance

    public static CurrentTransaction getInstance(DbEnv env)

  Gets the CurrentTransaction accessor for a specified Berkeley DB environment. This method always returns the same reference when called more than once with the same environment parameter.

  Parameters:
    `env` - is an open Berkeley DB environment.
  Returns:
    the CurrentTransaction accessor for the given environment, or null if the environment is not transactional.

### getEnv

    public final DbEnv getEnv()

  Returns the underlying Berkeley DB environment.

### isAutoCommit

    public final boolean isAutoCommit()

  Returns whether AUTO_COMMIT will be used for all non-cursor write operations when no transaction is active.

### isDirtyRead

    public final boolean isDirtyRead()

  Returns whether dirty-read is used for the current transaction.

### isNoWait

    public final boolean isNoWait()

  Returns whether no-wait is used for the current transaction.

### getTxn

    public final DbTxn getTxn()

  Returns the transaction associated with the current thread for this environment, or null if no transaction is active.

### beginTxn

    public final DbTxn beginTxn()
                         throws DbException

  Begins a new transaction for this environment and associates it with the current thread. If a transaction is already active for this environment and thread, a nested transaction will be created.

  Returns:
    the new transaction.
  Throws:
    `DbException` - if the transaction cannot be started, in which case any existing transaction is not affected.

### beginTxn

    public final DbTxn beginTxn(boolean dirtyRead,
                                boolean noWait)
                         throws DbException

  Begins a new transaction for this environment and associates it with the current thread. If a transaction is already active for this environment and thread, a nested transaction will be created.

  Parameters:
    `dirtyRead` - true if this transaction should read data that is modified by another transaction but not committed.
    `noWait` - true if this transaction should throw DbLockNotGrantedException instead of blocking when trying to access data that is locked by another transaction.
  Returns:
    the new transaction.
  Throws:
    `DbException` - if the transaction cannot be started, in which case any existing transaction is not affected.

### commitTxn

    public final DbTxn commitTxn()
                          throws DbException,
                                 IllegalStateException

  Commits the transaction that is active for the current thread for this environment and makes the parent transaction (if any) the current transaction.

  Returns:
    the parent transaction or null if the committed transaction was not nested.
  Throws:
    `DbException` - if an error occurs commiting the transaction. The transaction will still be closed and the parent transaction will become the current transaction.
    `IllegalStateException` - if no transaction is active for the current thread for this environement.

### abortTxn

    public final DbTxn abortTxn()
                         throws DbException,
                                IllegalStateException

  Aborts the transaction that is active for the current thread for this environment and makes the parent transaction (if any) the current transaction.

  Returns:
    the parent transaction or null if the aborted transaction was not nested.
  Throws:
    `DbException` - if an error occurs aborting the transaction. The transaction will still be closed and the parent transaction will become the current transaction.
    `IllegalStateException` - if no transaction is active for the current thread for this environement.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Berkeley DB version 4.2.52
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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