com.subshell.persistence.transaction
Interface Transaction

All Known Implementing Classes:
HibernateTransaction

public interface Transaction

A database transaction. Transaction instances can be obtained using Database.openTransaction(). See the package description on how to work with Transactions.

It is not intended that implementors be thread-safe. Instead, each client thread should obtain its own instance of Transaction.

Note: Implementors should make use of lazy initialization, that is, the real database connection should be created as late as possible.


Method Summary
 void commit()
          Commits this Transaction.
<T> Serializable
create(T o)
          Creates an object in the database.
<T> void
delete(T o)
          Deletes a persistent object from the database.
 boolean isCommitted()
          Returns whether this Transaction has been committed/rolled back.
<T> boolean
isPersistent(T o)
          Returns whether an object is persistent.
<T> T
load(Class<T> clazz, Serializable id)
          Loads an object from the database.
 void rollback()
          Rolls back this Transaction.
 

Method Detail

load

<T> T load(Class<T> clazz,
           Serializable id)
       throws PersistenceException
Loads an object from the database.

Parameters:
clazz - the object's class
id - the object's ID
Throws:
PersistenceException - when loading the object fails
TransactionCommittedException - when this Transaction has been commited/rolled back already

create

<T> Serializable create(T o)
                    throws PersistenceException
Creates an object in the database.

Parameters:
o - the object to create
Returns:
the identifier that has been assigned to the created object
Throws:
PersistenceException - when creating the object fails
TransactionCommittedException - when this Transaction has been commited/rolled back already

delete

<T> void delete(T o)
            throws PersistenceException
Deletes a persistent object from the database.

Parameters:
o - the object to delete
Throws:
PersistenceException - when deleting the object fails
TransactionCommittedException - when this Transaction has been commited/rolled back already

isPersistent

<T> boolean isPersistent(T o)
                     throws PersistenceException
Returns whether an object is persistent.

Throws:
PersistenceException - when there is a persistence-related error

commit

void commit()
            throws PersistenceException
Commits this Transaction. The Transaction cannot be reused once it has been committed.

Throws:
PersistenceException - when committing this Transaction fails
TransactionCommittedException - when this Transaction has been commited/rolled back already

rollback

void rollback()
              throws PersistenceException
Rolls back this Transaction. The Transaction cannot be reused once it has been rolled back.

Throws:
PersistenceException - when rolling back this Transaction fails
TransactionCommittedException - when this Transaction has been commited/rolled back already

isCommitted

boolean isCommitted()
                    throws PersistenceException
Returns whether this Transaction has been committed/rolled back.

Throws:
PersistenceException - when there is a persistence-related error


Copyright © 2004-2005 subshell GmbH. All Rights Reserved.