com.subshell.persistence.mapper
Class TransactionPersistenceMapper<T>

java.lang.Object
  extended by com.subshell.persistence.mapper.TransactionPersistenceMapper<T>
All Implemented Interfaces:
PersistenceMapper<T>

public abstract class TransactionPersistenceMapper<T>
extends Object
implements PersistenceMapper<T>

Abstract persistence mapper implementation which is provided with a Transaction.

Note: Subclasses must retain the (Class, Transaction) constructor which must be publicly accessible.


Constructor Summary
TransactionPersistenceMapper(Class<T> clazz, Transaction transaction)
          Creates a new TransactionPersistenceMapper.
 
Method Summary
 Serializable create(T o)
          Persists an object in the database.
 void delete(T o)
          Deletes a persistent object from the database.
protected  Transaction getTransaction()
          Returns the transaction associated with this persistence mapper.
 boolean isPersistent(T o)
          Returns whether an object is persistent.
 T load(Serializable id)
          Loads an object from the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionPersistenceMapper

public TransactionPersistenceMapper(Class<T> clazz,
                                    Transaction transaction)
Creates a new TransactionPersistenceMapper.

Parameters:
clazz - class of the objects this persistence mapper is supposed to handle
transaction - database transaction
Method Detail

load

public T load(Serializable id)
       throws PersistenceException
Loads an object from the database.

Specified by:
load in interface PersistenceMapper<T>
Parameters:
id - the object's ID
Throws:
PersistenceException - when loading the object fails
TransactionCommittedException - when the underlying Transaction has been commited/rolled back already

create

public Serializable create(T o)
                    throws PersistenceException
Persists an object in the database.

Specified by:
create in interface PersistenceMapper<T>
Parameters:
o - the object to persist
Returns:
the identifier that has been assigned to the persistent object
Throws:
PersistenceException - when persisting the object fails
TransactionCommittedException - when the underlying Transaction has been commited/rolled back already

delete

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

Specified by:
delete in interface PersistenceMapper<T>
Parameters:
o - the object to delete
Throws:
PersistenceException - when deleting the object fails
TransactionCommittedException - when the underlying Transaction has been commited/rolled back already

isPersistent

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

Specified by:
isPersistent in interface PersistenceMapper<T>
Throws:
PersistenceException - when there is a persistence-related error

getTransaction

protected Transaction getTransaction()
Returns the transaction associated with this persistence mapper.



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