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

## org.objectstyle.cayenne.access
Class Transaction

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

    public abstract class Transaction

extends java.lang.Object

A Cayenne transaction. Currently supports managing JDBC connections.

Since:
  1.1
Author:
  Andrus Adamchik

Field Summary
`protected java.util.Map` | `connections`
`protected TransactionDelegate` | `delegate`
`protected org.apache.log4j.Level` | `logLevel` Deprecated. since 1.2
`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
`void` | `addConnection(java.sql.Connection connection)` Deprecated. since 1.2 use `addConnection(String, Connection)`.
`boolean` | `addConnection(java.lang.String name, java.sql.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.
`java.sql.Connection` | `getConnection(java.lang.String name)`
`TransactionDelegate` | `getDelegate()`
`org.apache.log4j.Level` | `getLogLevel()` Deprecated. since 1.2 unused
`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.
`void` | `performQueries(QueryEngine engine, java.util.Collection queries, OperationObserver observer)` Deprecated. since 1.2 this method is not used in Cayenne and is deprecated. Thread-bound transactions should be used instead.
`abstract void` | `rollback()`
`void` | `setDelegate(TransactionDelegate delegate)`
`void` | `setLogLevel(org.apache.log4j.Level logLevel)` Deprecated. since 1.2 unused
`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 java.util.Map connections

### status

    protected int status

### delegate

    protected TransactionDelegate delegate

### logLevel

    protected org.apache.log4j.Level logLevel

  Deprecated. since 1.2

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.

### performQueries

    public void performQueries(QueryEngine engine,
                               java.util.Collection queries,
                               OperationObserver observer)
                        throws CayenneRuntimeException

  Deprecated. since 1.2 this method is not used in Cayenne and is deprecated. Thread-bound transactions should be used instead.

  Helper method that wraps a number of queries in this transaction, runs them, and commits or rolls back depending on the outcome. This method allows users to define their own custom Transactions and wrap Cayenne queries in them.

  Throws:
    `CayenneRuntimeException`

### getLogLevel

    public org.apache.log4j.Level getLogLevel()

  Deprecated. since 1.2 unused

### setLogLevel

    public void setLogLevel(org.apache.log4j.Level logLevel)

  Deprecated. since 1.2 unused

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

### addConnection

    public void addConnection(java.sql.Connection connection)
                       throws java.lang.IllegalStateException,
                              java.sql.SQLException,
                              CayenneException

  Deprecated. since 1.2 use `addConnection(String, Connection)`.

  Throws:
    `java.lang.IllegalStateException`
    `java.sql.SQLException`
    `CayenneException`

### commit

    public abstract void commit()
                         throws java.lang.IllegalStateException,
                                java.sql.SQLException,
                                CayenneException

  Throws:
    `java.lang.IllegalStateException`
    `java.sql.SQLException`
    `CayenneException`

### rollback

    public abstract void rollback()
                           throws java.lang.IllegalStateException,
                                  java.sql.SQLException,
                                  CayenneException

  Throws:
    `java.lang.IllegalStateException`
    `java.sql.SQLException`
    `CayenneException`

### getConnection

    public java.sql.Connection getConnection(java.lang.String name)

  Since:
    1.2

### addConnection

    public boolean addConnection(java.lang.String name,
                                 java.sql.Connection connection)
                          throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`
  Since:
    1.2

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

Copyright © 2001-2006 ObjectStyle.org All Rights Reserved.