EAF 7.6 API

com.lutris.appserver.server.sql
Interface DBTransaction


public interface DBTransaction

Used to perform database transactions.

Example - adding a new user:

         import org.enhydra.dods.DODS;
         import com.lutris.appserver.server.sql.*;

       DBTransaction transaction =
        DODS.getDatabaseManager().createTransaction(DATABASE_NAME);

       // NOTE: class CustomerDO implements Transaction { ... }
       // NOTE: An Object ID is automatically calculated by the constructor.
       CustomerDO customer = new CustomerDO();
       customer.setFirstName("Santa");
       customer.setLastName("Claus");

       // ... set all other CustomerFields ...

       //
       // Now add the new object to the database.
       //
       try {
           transaction.insert(customer);
           transaction.commit();
           System.out.println("Object ID is " + customer.get_OId());
       }
       catch (SQLException e) {
           transaction.rollback();
           throw e;
       }
       finally {
           transaction.release();
       }
 

Since:
LBS1.8
Version:
$Revision: 1.1 $
Author:
Kyle Clark

Method Summary
 void commit()
          Method to commit upates.
 DBQuery createQuery()
          Return a query for use with this TRANSACTION please!!!
 void delete(Transaction transaction)
          Method to delete an object in the database.
 java.lang.String getDatabaseName()
          Method return name of used database
 Transaction getDO(Transaction transaction)
          Method find a DO in the transaction
 Transaction getDO(Transaction transaction, int action)
          Method find a DO in the transaction
 boolean handleException(java.sql.SQLException e)
          Exception handeler.
 void insert(Transaction transaction)
          Method to insert an object in the database.
 void lockDO(Transaction cdo)
           
 boolean preventCacheQueries()
           
 void release()
          Frees all resources consumed by this transaction Connections are returned to the connection pool.
 void rollback()
          Method to rollback changes.
 void setDatabaseName(java.lang.String dbName)
          Method set name of used database
 void update(Transaction transaction)
          Method to update an object in the database.
 void write()
           
 

Method Detail

update

void update(Transaction transaction)
Method to update an object in the database.

Parameters:
transaction - Object that implements transaction interface.

delete

void delete(Transaction transaction)
Method to delete an object in the database.

Parameters:
transaction - Object that implements transaction interface.

insert

void insert(Transaction transaction)
Method to insert an object in the database.

Parameters:
transaction - Object that implements transaction interface.

commit

void commit()
            throws java.sql.SQLException
Method to commit upates.

Throws:
java.sql.SQLException - If a database access error occurs.

rollback

void rollback()
              throws java.sql.SQLException
Method to rollback changes.

Throws:
java.sql.SQLException - If a database access error occurs.

release

void release()
Frees all resources consumed by this transaction Connections are returned to the connection pool. Subsequent transactions via this object, will allocate a new set of resources (i.e. connection).


handleException

boolean handleException(java.sql.SQLException e)
Exception handeler. This object is should not be used for subsequent queries if this method returns false.

Returns:
boolean True if the exception can be handeled and the object is still valid, false otherwise.

getDO

Transaction getDO(Transaction transaction)
Method find a DO in the transaction

Parameters:
transaction - Object that implements transaction interface.
Returns:
DO if the oid was in the transaction, null if it was not WebDocWf extension

getDO

Transaction getDO(Transaction transaction,
                  int action)
Method find a DO in the transaction

Parameters:
transaction - Object that implements transaction interface.
action - if not NONE=0, the DO is found only woth the matching action
Returns:
DO if the oid was in the transaction, null if it was not WebDocWf extension

getDatabaseName

java.lang.String getDatabaseName()
Method return name of used database

Returns:
name of used database

setDatabaseName

void setDatabaseName(java.lang.String dbName)
Method set name of used database

Parameters:
dbName - name of used database

write

void write()
           throws java.sql.SQLException
Throws:
java.sql.SQLException

lockDO

void lockDO(Transaction cdo)
            throws java.sql.SQLException
Throws:
java.sql.SQLException

createQuery

DBQuery createQuery()
                    throws java.sql.SQLException
Return a query for use with this TRANSACTION please!!!

Returns:
The query object.
Throws:
java.sql.SQLException - if a SQL error occurs.

preventCacheQueries

boolean preventCacheQueries()

EAF 7.6 API