Package org.apache.cayenne.tx
Interface Transaction
- All Known Implementing Classes:
BaseTransaction
,CayenneTransaction
,ExternalTransaction
public interface Transaction
Cayenne Transaction interface.
- Since:
- 4.0
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(TransactionListener listener) void
begin()
Starts a Transaction.void
commit()
Returns all connections associated with the transaction.getOrCreateConnection
(String connectionName, DataSource dataSource) Retrieves a connection for the given symbolic name.boolean
Is this transaction managed by external transaction managerboolean
void
rollback()
void
-
Method Details
-
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
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
-
isExternal
boolean isExternal()Is this transaction managed by external transaction manager
-