uk.co.kimble.cobra
Class Transaction

java.lang.Object
  |
  +--uk.co.kimble.cobra.Transaction
Direct Known Subclasses:
Transaction

public class Transaction
extends java.lang.Object

The Transaction class enables a set of operations on objects to be grouped into a single operation that will succeed or fail as a whole. For example you may not want a customer record to be updated if the update of the customer's order failed.


Constructor Summary
Transaction()
          Constructor
 
Method Summary
 void begin()
          Start a new transaction, any old work is forgotten
 void commit()
          Commit the unit of work, because COBRA can support multiple databases the semantics of a COBRA transaction differ slightly from an RDBMS transaction.
 void delete(PersistentObject po)
          add an object to be deleted to the unit of work
 void delete(PersistentObject po, PersistentCriteria c)
          add an object to be deleted to the unit of work
 void save(PersistentObject po)
          add an object to be saved (inserted or updated) to the unit of work for the database
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Transaction

public Transaction()
            throws PersistentException
Constructor
Method Detail

begin

public void begin()
Start a new transaction, any old work is forgotten

save

public void save(PersistentObject po)
          throws PersistentException
add an object to be saved (inserted or updated) to the unit of work for the database
Parameters:
po - Persistent object to be saved (persisted)

delete

public void delete(PersistentObject po)
            throws PersistentException
add an object to be deleted to the unit of work
Parameters:
po - Persistent Object to be deleted

delete

public void delete(PersistentObject po,
                   PersistentCriteria c)
            throws PersistentException
add an object to be deleted to the unit of work
Parameters:
po - Persistent Object to be deleted

commit

public void commit()
            throws PersistentException
Commit the unit of work, because COBRA can support multiple databases the semantics of a COBRA transaction differ slightly from an RDBMS transaction. Transaction works through the units of work for each database, each is committed as a single database transaction, if the commit succeeds the work is removed from the Transaction, if it fails a rollback is performed and the commit fails. It is then up to the application to deal with retrying the commit Where objects are located can therefore be quite important. Generally only a single database is used for writing, the ability to access multiple databases is useful where information should be read from legacy systems.
Throws:
PersistentException -