public abstract class BaseTransaction extends Object implements Transaction
| Modifier and Type | Field and Description |
|---|---|
protected Map<String,Connection> |
connections |
protected Collection<TransactionListener> |
listeners |
protected int |
status |
protected static int |
STATUS_ACTIVE |
protected static int |
STATUS_COMMITTED |
protected static int |
STATUS_COMMITTING |
protected static int |
STATUS_MARKED_ROLLEDBACK |
protected static int |
STATUS_NO_TRANSACTION |
protected static int |
STATUS_ROLLEDBACK |
protected static int |
STATUS_ROLLING_BACK |
| Modifier | Constructor and Description |
|---|---|
protected |
BaseTransaction()
Creates new inactive transaction.
|
| Modifier and Type | Method and Description |
|---|---|
protected Connection |
addConnection(String connectionName,
Connection connection) |
void |
addListener(TransactionListener listener) |
void |
begin()
Starts a Transaction.
|
static void |
bindThreadTransaction(Transaction transaction)
Binds a Transaction to the current thread.
|
protected void |
close()
Closes all connections associated with transaction.
|
void |
commit() |
protected void |
connectionAdded(Connection connection) |
Map<String,Connection> |
getConnections()
Returns all connections associated with the transaction.
|
protected Connection |
getExistingConnection(String name) |
Connection |
getOrCreateConnection(String connectionName,
DataSource dataSource)
Retrieves a connection for the given symbolic name.
|
static Transaction |
getThreadTransaction()
Returns a Transaction associated with the current thread, or null if
there is no such Transaction.
|
boolean |
isRollbackOnly() |
protected abstract void |
processCommit() |
protected abstract void |
processRollback() |
void |
rollback() |
void |
setRollbackOnly() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisExternalprotected static final int STATUS_ACTIVE
protected static final int STATUS_COMMITTING
protected static final int STATUS_COMMITTED
protected static final int STATUS_ROLLEDBACK
protected static final int STATUS_ROLLING_BACK
protected static final int STATUS_NO_TRANSACTION
protected static final int STATUS_MARKED_ROLLEDBACK
protected Map<String,Connection> connections
protected Collection<TransactionListener> listeners
protected int status
public static void bindThreadTransaction(Transaction transaction)
public static Transaction getThreadTransaction()
public void setRollbackOnly()
setRollbackOnly in interface Transactionpublic boolean isRollbackOnly()
isRollbackOnly in interface Transactionpublic void addListener(TransactionListener listener)
addListener in interface Transactionpublic void begin()
begin in interface Transactionpublic void commit()
commit in interface Transactionprotected abstract void processCommit()
public void rollback()
rollback in interface Transactionprotected abstract void processRollback()
public Map<String,Connection> getConnections()
TransactiongetConnections in interface Transactionpublic Connection getOrCreateConnection(String connectionName, DataSource dataSource) throws SQLException
TransactiongetOrCreateConnection in interface TransactionconnectionName - a symbolic name of the connection. Cayenne DataNodes generate a name in the form of
"DataNode.Connection.nodename".dataSource - DataSource that provides new connections.SQLExceptionprotected Connection getExistingConnection(String name)
protected Connection addConnection(String connectionName, Connection connection)
protected void connectionAdded(Connection connection)
protected void close()
Copyright © 2001–2023 Apache Cayenne. All rights reserved.