com.ivata.mask.persistence
Interface PersistenceSession

All Superinterfaces:
java.io.Serializable

public interface PersistenceSession
extends java.io.Serializable

A persistence session must be opened (by calling PersistenceManager.openSession before performing any other persistence operation. It can be considered analagous to a transaction in a database environment.

Since:
ivata masks 0.3 (2004-03-27)
Version:
$Revision: 1.5 $
Author:
Colin MacLeod colin.macleod@ivata.com
See Also:
PersistenceManager

Method Summary
 void cancel()
           Cancel all operations performed in this session.
 void close()
           Commit any changes made in this transaction to the data store.
 java.sql.Connection getConnection()
           Access the data connection wrapped by this persistence session.
 java.lang.Object getSystemSession()
          Return a system-specific (i.e.
 

Method Detail

cancel

public void cancel()
            throws PersistenceException

Cancel all operations performed in this session. These operations should then be rolled back in close

Throws:
PersistenceException - if the session cannot be cancelled for any reason.

close

public void close()
           throws PersistenceException

Commit any changes made in this transaction to the data store. You must call this method after performing persistence methods - use it within a finally block as shown in the example code.

TODO: link to demo code reference here.

Throws:
PersistenceException - if the session cannot be closed/committed for any reason.

getConnection

public java.sql.Connection getConnection()
                                  throws PersistenceException

Access the data connection wrapped by this persistence session. You should think twice before using this method - not all implementations of a persistence layer may use a database, and therefore this may not always be appropriate.

Returns:
valid database connection for the underlying data store.
Throws:
PersistenceException - if the database connection cannot be retrieved for any reason (including lack of support by the underlying persistence layer).

getSystemSession

public java.lang.Object getSystemSession()
Return a system-specific (i.e. ivata masks knows nothing about it's specific implementation) session object - this is stored when PersistenceManager.openSession is called with an object parameter.

Returns:
system-specific session object, or null if none was set.


Copyright © 2001-2005 ivata limited. All Rights Reserved.