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, wait
isExternal
protected 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 Transaction
public boolean isRollbackOnly()
isRollbackOnly
in interface Transaction
public void addListener(TransactionListener listener)
addListener
in interface Transaction
public void begin()
begin
in interface Transaction
public void commit()
commit
in interface Transaction
protected abstract void processCommit()
public void rollback()
rollback
in interface Transaction
protected abstract void processRollback()
public Map<String,Connection> getConnections()
Transaction
getConnections
in interface Transaction
public Connection getOrCreateConnection(String connectionName, DataSource dataSource) throws SQLException
Transaction
getOrCreateConnection
in interface Transaction
connectionName
- a symbolic name of the connection. Cayenne DataNodes generate a name in the form of
"DataNode.Connection.nodename".dataSource
- DataSource that provides new connections.SQLException
protected Connection getExistingConnection(String name)
protected Connection addConnection(String connectionName, Connection connection)
protected void connectionAdded(Connection connection)
protected void close()
Copyright © 2001–2019 Apache Cayenne. All rights reserved.