Package org.apache.cayenne.tx
Interface Transaction
-
- All Known Implementing Classes:
BaseTransaction,CayenneTransaction,ExternalTransaction
public interface TransactionCayenne Transaction interface.- Since:
- 4.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddListener(TransactionListener listener)voidbegin()Starts a Transaction.voidcommit()Map<String,Connection>getConnections()Returns all connections associated with the transaction.ConnectiongetOrCreateConnection(String connectionName, DataSource dataSource)Retrieves a connection for the given symbolic name.booleanisExternal()Is this transaction managed by external transaction managerbooleanisRollbackOnly()voidrollback()voidsetRollbackOnly()
-
-
-
Method Detail
-
begin
void begin()
Starts a Transaction. If Transaction is not started explicitly, it will be started when the first connection is added.
-
commit
void commit()
-
rollback
void rollback()
-
setRollbackOnly
void setRollbackOnly()
-
isRollbackOnly
boolean isRollbackOnly()
-
getOrCreateConnection
Connection getOrCreateConnection(String connectionName, DataSource dataSource) throws SQLException
Retrieves a connection for the given symbolic name. If it does not exists, creates a new connection using provided DataSource, and registers it internally.- Parameters:
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.- Returns:
- a connection that participates in the current transaction.
- Throws:
SQLException
-
getConnections
Map<String,Connection> getConnections()
Returns all connections associated with the transaction.- Returns:
- connections associated with the transaction.
-
addListener
void addListener(TransactionListener listener)
-
isExternal
boolean isExternal()
Is this transaction managed by external transaction manager
-
-