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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addListener(TransactionListener listener)
void
begin()
Starts a Transaction.void
commit()
Map<String,Connection>
getConnections()
Returns all connections associated with the transaction.Connection
getOrCreateConnection(String connectionName, DataSource dataSource)
Retrieves a connection for the given symbolic name.boolean
isExternal()
Is this transaction managed by external transaction managerboolean
isRollbackOnly()
void
rollback()
void
setRollbackOnly()
-
-
-
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
-
-