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

## org.apache.cayenne.access
Class Transaction

    java.lang.Object
      org.apache.cayenne.access.Transaction

    public abstract class Transaction

extends Object

A Cayenne transaction. Currently supports managing JDBC connections.

Since:
  1.1

Field Summary
`protected Map<String,Connection>` | `connections`
`protected TransactionDelegate` | `delegate`
`protected int` | `status`
`static int` | `STATUS_ACTIVE`
`static int` | `STATUS_COMMITTED`
`static int` | `STATUS_COMMITTING`
`static int` | `STATUS_MARKED_ROLLEDBACK`
`static int` | `STATUS_NO_TRANSACTION`
`static int` | `STATUS_ROLLEDBACK`
`static int` | `STATUS_ROLLING_BACK`

Constructor Summary
`protected` | `Transaction()` Creates new inactive transaction.

Method Summary
`boolean` | `addConnection(String name, Connection connection)`
`abstract void` | `begin()` Starts a Transaction.
`static void` | `bindThreadTransaction(Transaction transaction)` Binds a Transaction to the current thread.
`abstract void` | `commit()`
`static Transaction` | `externalTransaction(TransactionDelegate delegate)` Factory method returning a new transaction instance that would NOT propagate commit/rollback to participating connections.
`Connection` | `getConnection(String name)`
`TransactionDelegate` | `getDelegate()`
`int` | `getStatus()`
`static Transaction` | `getThreadTransaction()` Returns a Transaction associated with the current thread, or null if there is no such Transaction.
`static Transaction` | `internalTransaction(TransactionDelegate delegate)` Factory method returning a new transaction instance that would propagate commit/rollback to participating connections.
`static Transaction` | `noTransaction()` Factory method returning a transaction instance that does not alter the state of participating connections in any way.
`abstract void` | `rollback()`
`void` | `setDelegate(TransactionDelegate delegate)`
`void` | `setRollbackOnly()`
`void` | `setStatus(int status)`

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

Field Detail

### STATUS_ACTIVE

    public static final int STATUS_ACTIVE

See Also:
  Constant Field Values

### STATUS_COMMITTING

    public static final int STATUS_COMMITTING

See Also:
  Constant Field Values

### STATUS_COMMITTED

    public static final int STATUS_COMMITTED

See Also:
  Constant Field Values

### STATUS_ROLLEDBACK

    public static final int STATUS_ROLLEDBACK

See Also:
  Constant Field Values

### STATUS_ROLLING_BACK

    public static final int STATUS_ROLLING_BACK

See Also:
  Constant Field Values

### STATUS_NO_TRANSACTION

    public static final int STATUS_NO_TRANSACTION

See Also:
  Constant Field Values

### STATUS_MARKED_ROLLEDBACK

    public static final int STATUS_MARKED_ROLLEDBACK

See Also:
  Constant Field Values

### connections

    protected Map<String,Connection> connections

### status

    protected int status

### delegate

    protected TransactionDelegate delegate

Constructor Detail

### Transaction

    protected Transaction()

  Creates new inactive transaction.

Method Detail

### bindThreadTransaction

    public static void bindThreadTransaction(Transaction transaction)

  Binds a Transaction to the current thread.

  Since:
    1.2

### getThreadTransaction

    public static Transaction getThreadTransaction()

  Returns a Transaction associated with the current thread, or null if there is no such Transaction.

  Since:
    1.2

### internalTransaction

    public static Transaction internalTransaction(TransactionDelegate delegate)

  Factory method returning a new transaction instance that would propagate commit/rollback to participating connections. Connections will be closed when commit or rollback is called.

### externalTransaction

    public static Transaction externalTransaction(TransactionDelegate delegate)

  Factory method returning a new transaction instance that would NOT propagate commit/rollback to participating connections. Connections will still be closed when commit or rollback is called.

### noTransaction

    public static Transaction noTransaction()

  Factory method returning a transaction instance that does not alter the state of participating connections in any way. Commit and rollback methods do not do anything.

### getDelegate

    public TransactionDelegate getDelegate()

### setDelegate

    public void setDelegate(TransactionDelegate delegate)

### getStatus

    public int getStatus()

### setRollbackOnly

    public void setRollbackOnly()

### setStatus

    public void setStatus(int status)

### begin

    public abstract void begin()

  Starts a Transaction. If Transaction is not started explicitly, it will be started when the first connection is added.

### commit

    public abstract void commit()
                         throws IllegalStateException,
                                SQLException,
                                CayenneException

  Throws:
    `IllegalStateException`
    `SQLException`
    `CayenneException`

### rollback

    public abstract void rollback()
                           throws IllegalStateException,
                                  SQLException,
                                  CayenneException

  Throws:
    `IllegalStateException`
    `SQLException`
    `CayenneException`

### getConnection

    public Connection getConnection(String name)

  Since:
    1.2

### addConnection

    public boolean addConnection(String name,
                                 Connection connection)
                          throws SQLException

  Throws:
    `SQLException`
  Since:
    1.2

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

Copyright © 2001-2008 Apache Cayenne. All Rights Reserved.