Oracle Fusion Middleware Java API Reference for Oracle ADF Mobile Client
11g Release 1 (11.1.1)

E17503-02

oracle.jbo.server
Class DBTransactionImpl2

java.lang.Object
  extended by oracle.jbo.server.DBTransactionImpl
      extended by oracle.jbo.server.DBTransactionImpl2
All Implemented Interfaces:
PCollManagerHelper, JboTransAttrValidationManager, JboTransValidationManager, DBTransaction, ValidationManager, Transaction

public class DBTransactionImpl2
extends DBTransactionImpl

Implementation of DBTransaction interface for representing both "connected" and "not connected" state. In pre 9.0.3 versions the disconnected and connected state implementation was provided by NullDBTransactionImpl and DBTransactionImpl respectivey. DBTransactionImpl instance was created only when clients initiated the acquisition of a jdbc connection by calling the one of Transaction.connect() or Transaction.connectToDataSource() methods.

Beginning from 9.0.3 Creation of root application module results in creation DBTransactionImpl2 instance in disconnected state. Later when clients request acquistion of jdbc connection this instance migrates from disconnected to connected state.

Since:
JDeveloper 9.0.3
See Also:
oracle.jbo.server.DatabaseTransactionFactory

Field Summary
static java.lang.Class CLASS_INSTANCE
           
 
Fields inherited from class oracle.jbo.server.DBTransactionImpl
MAX_CURSORS_UNINITIALIZED, mConnectionMetaData, mDMLOperationTimeOut, mLongRunningDMLOperationHandles, POST_ABORT_ON_FIRST_EXCEPTION, POST_ALL_NO_RESET_ON_EXCEPTION, POST_ALL_RESET_ON_EXCEPTION
 
Fields inherited from interface oracle.jbo.server.DBTransaction
DEFAULT
 
Fields inherited from interface oracle.jbo.Transaction
DML_OPERATION_TIMEOUT_WAIT_FOREVER, LOCK_NONE, LOCK_OPTIMISTIC, LOCK_OPTUPDATE, LOCK_PESSIMISTIC
 
Constructor Summary
DBTransactionImpl2()
           
 
Method Summary
 CallableStatement createCallableStatement(java.lang.String str, int noRowsPrefetch)
          Implementation of createCallableStatement method.
 PreparedStatement createPreparedStatement(java.lang.String str, int noRowsPrefetch)
          Implementation of createPreparedStatement method.
 Statement createStatement(int noRowsPrefetch)
          Implementation of createStatement method.
 void rollback()
          Discards all modifications made in this transaction.
 
Methods inherited from class oracle.jbo.server.DBTransactionImpl
addLongRunningDMLOperationHandle, addToValidationListeners, addTransactionListener, addTransactionListenerNoCheck, addTransactionPostListener, addTransactionPostListenerNoCheck, addTransactionStateListener, addViewClearCacheListener, applyChangeSet, cancelDMLOperations, checkConnected, clearEntityCache, closeTransaction, commit, commitAndSaveChangeSet, connect, connect, connect, connect, connectToDataSource, connectToDataSource, connectToDataSource, connectToDataSource, createPreparedStatement, createRef, createStatement, createViewObjectFromQueryClauses, disconnect, disconnect, doCommit, doRollback, dumpQueryResult, executeCommand, findEntityCache, getBatchPostExceptionThreshold, getConnectionMetadata, getDMLOperationTimeOut, getEntityCache, getEntityCache, getJdbcConnection, getLockingMode, getPersistManagerConnection, getPostChangesFlag, getPostThreshold, getRootApplicationModule, getSession, getSQLBuilder, getSyncLock, getTransactionHandler, getTransactionState, getTransAttrValidationList, getTransAttrValidationManager, getTransAttrValidations, getTransValidationList, getTransValidationManager, getTransValidations, getTxnApplicationModuleImpl, getValidationThreshold, hasRollbackSavePoint, isBundledExceptionMode, isClearCacheOnCommit, isClearCacheOnRollback, isConnected, isConnected, isDirty, isForceDeferValidation, isTrackNewAndModifiedRowsOnly, lookupEntityCache, postChanges, postChanges, putTransAttrValEntry, putTransValEntry, reconnect, reconnect, removeChangeSet, removeLongRunningDMLOperationHandle, removeTransactionListener, removeTransactionPostListener, removeTransactionStateListener, removeViewClearCacheListener, setBatchModeForEntity, setBundledExceptionMode, setClearCacheOnCommit, setClearCacheOnRollback, setDMLOperationTimeOut, setForceDeferValidation, setLockingMode, setTransactionHandler, setValidationThreshold, validate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_INSTANCE

public static final java.lang.Class CLASS_INSTANCE
Constructor Detail

DBTransactionImpl2

public DBTransactionImpl2()
Method Detail

createStatement

public Statement createStatement(int noRowsPrefetch)
Implementation of createStatement method.

Specified by:
createStatement in interface DBTransaction
Overrides:
createStatement in class DBTransactionImpl
Parameters:
noRowsPrefetch - the number of rows to prefetch when executing this statement's query.
Returns:
a JDBC Statement instance.
Throws:
NotConnectedException - if no jdbc connection was acquired

createCallableStatement

public CallableStatement createCallableStatement(java.lang.String str,
                                                 int noRowsPrefetch)
Implementation of createCallableStatement method.

Overrides:
createCallableStatement in class DBTransactionImpl
Throws:
NotConnectedException - if no jdbc connection was acquired

createPreparedStatement

public PreparedStatement createPreparedStatement(java.lang.String str,
                                                 int noRowsPrefetch)
Implementation of createPreparedStatement method.

Specified by:
createPreparedStatement in interface DBTransaction
Overrides:
createPreparedStatement in class DBTransactionImpl
Parameters:
str - the PreparedStatement instance's SQL statement.
noRowsPrefetch - the number of rows to prefetch when executing this statement's query. If this parameter is set to DBTransaction.DEFAULT, then the default value from the jdbc driver is used.
Returns:
a JDBC PreparedStatement instance.
Throws:
NotConnectedException - if no jdbc connection was acquired

rollback

public void rollback()
Description copied from class: DBTransactionImpl
Discards all modifications made in this transaction. This method is called on the Application Module's transaction. For example:

 appMod.getTransaction().rollback();
 
When this method is invoked, beforeRollback events are posted to the listeners, the changes are discarded, afterRollback events are posted, and transient listeners are deleted from the transaction. For both events, non-transient listeners preceed transient listeners.

In the following example, a method named updateAttr has been implemented to update a row of a View Object vo with the value newAttrVal. If updateAttr succeeds (returns true), the code commits the transaction; otherwise, it rolls the transaction back:

 // Assume that appMod has been declared and initialized elsewhere.
 try
 {
   if (updateAttr(vo, newAttrVal))
   {
     // Commit changes to the database, making
     // updated data available to other Application Modules.
     appMod.getTransaction().commit();
     System.out.println("\n Transaction committed. \n");
   }
   else
   {
     appMod.getTransaction().rollback();
     System.out.println("\n Transaction rolled back. \n");
   }
 }
 catch (Exception e)
 {
   e.printStackTrace();
 }
 

Note, if your Application Module is an EJB session bean, a new transaction is started for you automatically after calling rollback. You do not have to explicitly start a new transaction.

Specified by:
rollback in interface Transaction
Overrides:
rollback in class DBTransactionImpl
See Also:
DBTransaction, TransactionListener.afterRollback(TransactionEvent), TransactionListener.beforeRollback(TransactionEvent)

Oracle Fusion Middleware Java API Reference for Oracle ADF Mobile Client
11g Release 1 (11.1.1)

E17503-02

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.