DODS 7.6 API

com.lutris.appserver.server.sql.standard
Class StandardDBTransaction

java.lang.Object
  extended by com.lutris.appserver.server.sql.standard.StandardDBTransaction
All Implemented Interfaces:
CachedDBTransaction, DBTransaction
Direct Known Subclasses:
InformixDBTransaction, OracleDBTransaction

public class StandardDBTransaction
extends java.lang.Object
implements CachedDBTransaction

Standard implementation of SQL database transaction.

Since:
LBS1.8
Version:
$Revision: 1.11 $
Author:
Kyle Clark
See Also:
DBTransaction

Nested Class Summary
protected  class StandardDBTransaction.DOAction
           
 
Field Summary
protected  boolean _preventCacheQueries
           
protected  boolean aggregateModifications
           
protected  DOCache cache
           
protected  int CACHE_SIZE
           
protected  int COMPLEX_QUERY_CACHE_SIZE
           
protected  DBConnection conn
           
protected  java.lang.String databaseName
          Name of used database
protected  int dbLockCounter
           
protected static int DELETE
           
protected  java.util.Vector deletedRefs
           
protected  boolean firstWrite
           
protected  java.util.HashMap hmpObjectTransaction
           
protected  int id
           
protected static int INSERT
           
protected  boolean isAutoWrite
           
protected  boolean isTransactionCaches
           
protected static int nextId
           
protected static int NONE
           
protected  boolean released
           
protected  int SIMPLE_QUERY_CACHE_SIZE
           
protected  int SIZE_DELTA
           
protected  boolean sqlBatch
           
protected  Transaction[] trans
           
protected  int[] transAction
           
protected  int transIdx
           
protected static int UPDATE
           
protected  java.util.Vector vecAlreadyHidden
           
protected  java.util.Vector vecExecutedTransaction
           
protected  java.util.Vector vecSortedTransaction
           
 
Constructor Summary
protected StandardDBTransaction()
          This constructor is only for use in inherited class.
protected StandardDBTransaction(DBConnection conn)
          Construct a transaction object for use on the supplied dB connection.
 
Method Summary
 void addDeletedDO(CoreDO DO)
           
 java.util.List checkChanged(java.lang.String tableName, QueryCacheItem queryItem, Transaction[] array)
           
 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.
 void dontAggregateDOModifications()
           
protected  void finalize()
          If this object has not been released, this method ensures that garbage collection does so.
 boolean getAutoWrite()
          Method returns value of a data member.
 java.lang.String getDatabaseName()
          Method return name of used database
 java.util.Vector getDeletedDOs()
           
 Transaction getDO(Transaction transaction)
           
 Transaction getDO(Transaction transaction, int action)
          Method find a DO in the transaction
 CoreDO[] getDOs()
          Gets an array of DOs.
 DOCache getTransactionCache()
          Method return transaction Cache
 boolean handleException(java.sql.SQLException e)
          Exception handeler.
 boolean hideCacheEntries()
           
 void insert(Transaction transaction)
          Method to insert an object in the database.
 boolean isFirstWrite()
           
 boolean isHolding()
           
 boolean isReleased()
          Method to ensure this object is still valid.
 boolean isSQLbatch()
           
 boolean isTableModified(java.lang.String tableName)
          Returns indicator whether the table defined with tableName parameter was changed in the transaction (if there were any inserts and/or deletes and/or updates).
 void lockDO(Transaction cdo)
           
protected  void logDebug(java.lang.String str)
          Logging.
 boolean preventCacheQueries()
           
protected  void readConfigValues()
           
 void release()
          Frees all resources consumed by this transaction Connections are returned to the connection pool.
 void resetDeletedDOs()
           
 void revealCacheEntries()
           
 void rollback()
          Method to rollback changes.
 void saveDirtyDOs()
           
 void setDatabaseName(java.lang.String dbName)
          Method set name of used database
 void setFirstWrite(boolean newfw)
           
 void update(Transaction transaction)
          Method to update an object in the database.
protected  void validate()
          Method to ensure this object is still valid.
 boolean wasReadOnly()
          Although it's internally used to skip uneccessary commits against the database, this information is made publicly accessible through this method.
 void write()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

protected int id

nextId

protected static int nextId

conn

protected DBConnection conn

released

protected boolean released

_preventCacheQueries

protected boolean _preventCacheQueries

vecAlreadyHidden

protected java.util.Vector vecAlreadyHidden

vecExecutedTransaction

protected java.util.Vector vecExecutedTransaction

vecSortedTransaction

protected java.util.Vector vecSortedTransaction

hmpObjectTransaction

protected java.util.HashMap hmpObjectTransaction

trans

protected Transaction[] trans

transAction

protected int[] transAction

transIdx

protected int transIdx

dbLockCounter

protected int dbLockCounter

SIZE_DELTA

protected final int SIZE_DELTA
See Also:
Constant Field Values

CACHE_SIZE

protected final int CACHE_SIZE
See Also:
Constant Field Values

COMPLEX_QUERY_CACHE_SIZE

protected final int COMPLEX_QUERY_CACHE_SIZE
See Also:
Constant Field Values

SIMPLE_QUERY_CACHE_SIZE

protected final int SIMPLE_QUERY_CACHE_SIZE
See Also:
Constant Field Values

cache

protected DOCache cache

deletedRefs

protected java.util.Vector deletedRefs

INSERT

protected static final int INSERT
See Also:
Constant Field Values

UPDATE

protected static final int UPDATE
See Also:
Constant Field Values

DELETE

protected static final int DELETE
See Also:
Constant Field Values

isTransactionCaches

protected boolean isTransactionCaches

isAutoWrite

protected boolean isAutoWrite

sqlBatch

protected boolean sqlBatch

firstWrite

protected boolean firstWrite

NONE

protected static final int NONE
See Also:
Constant Field Values

databaseName

protected java.lang.String databaseName
Name of used database


aggregateModifications

protected boolean aggregateModifications
Constructor Detail

StandardDBTransaction

protected StandardDBTransaction(DBConnection conn)
                         throws java.sql.SQLException
Construct a transaction object for use on the supplied dB connection.

Parameters:
conn - The database connection to use.
Throws:
java.sql.SQLException - If a database access error occurs.

StandardDBTransaction

protected StandardDBTransaction()
This constructor is only for use in inherited class. Don't direct call.

Method Detail

getDO

public Transaction getDO(Transaction transaction)
Specified by:
getDO in interface DBTransaction

getDO

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

Specified by:
getDO in interface DBTransaction
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

update

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

Specified by:
update in interface DBTransaction
Parameters:
transaction - Object that implements transaction interface.

delete

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

Specified by:
delete in interface DBTransaction
Parameters:
transaction - Object that implements transaction interface.

insert

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

Specified by:
insert in interface DBTransaction
Parameters:
transaction - Object that implements transaction interface.

commit

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

Contains WebDocWf bug fix, transaction needs to be cleared

Specified by:
commit in interface DBTransaction
Throws:
java.sql.SQLException - If a database access error occurs.
DBRowUpdateException - If a version error occurs.

hideCacheEntries

public boolean hideCacheEntries()
                         throws java.sql.SQLException
Throws:
java.sql.SQLException

revealCacheEntries

public void revealCacheEntries()

rollback

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

Contains WebDocWf bug fix, transaction needs to be cleared

Specified by:
rollback in interface DBTransaction
Throws:
java.sql.SQLException - If a database access error occurs.

release

public 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). contains WebDocWf bug fix, transaction needs to be cleared

Specified by:
release in interface DBTransaction

handleException

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

Specified by:
handleException in interface DBTransaction
Returns:
boolean True if the exception can be handeled and the object is still valid, false otherwise.

validate

protected void validate()
                 throws java.sql.SQLException
Method to ensure this object is still valid. Once this object has been released it cannot be used any more.

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

isReleased

public boolean isReleased()
Method to ensure this object is still valid. Once this object has been released it cannot be used any more.

Specified by:
isReleased in interface CachedDBTransaction
Returns:
boolean True if the transaction is released, otherwise false

finalize

protected void finalize()
If this object has not been released, this method ensures that garbage collection does so.

Overrides:
finalize in class java.lang.Object

logDebug

protected void logDebug(java.lang.String str)
Logging. For debuging only, since it effects all Query objects.

Parameters:
str - The data to log.

getDatabaseName

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

Specified by:
getDatabaseName in interface DBTransaction
Returns:
name of used database

setDatabaseName

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

Specified by:
setDatabaseName in interface DBTransaction
Parameters:
dbName - name of used database

getDOs

public CoreDO[] getDOs()
Gets an array of DOs.

Specified by:
getDOs in interface CachedDBTransaction
Returns:
array of DOs from this transaction

saveDirtyDOs

public void saveDirtyDOs()
Specified by:
saveDirtyDOs in interface CachedDBTransaction

write

public void write()
           throws java.sql.SQLException
Specified by:
write in interface DBTransaction
Throws:
java.sql.SQLException - If a database access error occurs.
DBRowUpdateException - If a version error occurs.

getTransactionCache

public DOCache getTransactionCache()
Method return transaction Cache

Specified by:
getTransactionCache in interface CachedDBTransaction
Returns:
implementation of DOCache

getDeletedDOs

public java.util.Vector getDeletedDOs()
Specified by:
getDeletedDOs in interface CachedDBTransaction

addDeletedDO

public void addDeletedDO(CoreDO DO)
Specified by:
addDeletedDO in interface CachedDBTransaction

resetDeletedDOs

public void resetDeletedDOs()
Specified by:
resetDeletedDOs in interface CachedDBTransaction

lockDO

public void lockDO(Transaction cdo)
            throws java.sql.SQLException
Specified by:
lockDO in interface DBTransaction
Throws:
java.sql.SQLException

preventCacheQueries

public boolean preventCacheQueries()
Specified by:
preventCacheQueries in interface DBTransaction
Returns:
true if this transaction has executed a statement against database, so cached queries are obsolete

createQuery

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

Specified by:
createQuery in interface DBTransaction
Returns:
The query object.
Throws:
java.sql.SQLException - if a SQL error occurs.

dontAggregateDOModifications

public void dontAggregateDOModifications()
Specified by:
dontAggregateDOModifications in interface CachedDBTransaction

readConfigValues

protected void readConfigValues()

getAutoWrite

public boolean getAutoWrite()
Method returns value of a data member.

Specified by:
getAutoWrite in interface CachedDBTransaction
Returns:
value of config parameter AutoWrite true means all DOs are writen into database, as they come in false - no writes are done implicitly

isSQLbatch

public boolean isSQLbatch()

isFirstWrite

public boolean isFirstWrite()
Specified by:
isFirstWrite in interface CachedDBTransaction

setFirstWrite

public void setFirstWrite(boolean newfw)
Specified by:
setFirstWrite in interface CachedDBTransaction

wasReadOnly

public boolean wasReadOnly()
Description copied from interface: CachedDBTransaction
Although it's internally used to skip uneccessary commits against the database, this information is made publicly accessible through this method. Application may decide would it call a commit method or not thus improving performance a bit more.

Specified by:
wasReadOnly in interface CachedDBTransaction
Returns:
true if no writes happened

isHolding

public boolean isHolding()
Specified by:
isHolding in interface CachedDBTransaction

checkChanged

public java.util.List checkChanged(java.lang.String tableName,
                                   QueryCacheItem queryItem,
                                   Transaction[] array)
Specified by:
checkChanged in interface CachedDBTransaction

isTableModified

public boolean isTableModified(java.lang.String tableName)
Returns indicator whether the table defined with tableName parameter was changed in the transaction (if there were any inserts and/or deletes and/or updates).

Specified by:
isTableModified in interface CachedDBTransaction
Returns:
true if the table was changed in the transaction.

DODS 7.6 API