Business Components

oracle.jbo.server
Class DBTransactionImpl2

java.lang.Object
  |
  +--oracle.jbo.server.DBTransactionImpl
        |
        +--oracle.jbo.server.DBTransactionImpl2
All Implemented Interfaces:
DBTransaction, oracle.jbo.pcoll.PCollManagerHelper, Transaction, oracle.jbo.server.TransactionManager, ValidationManager

public class DBTransactionImpl2
extends DBTransactionImpl


Fields inherited from class oracle.jbo.server.DBTransactionImpl
MAX_CURSORS_UNINITIALIZED, mConnectionCredentials, mInternalCredentials, mSQLBuilder, mTxnListeners
 
Fields inherited from interface oracle.jbo.server.DBTransaction
DEFAULT
 
Fields inherited from interface oracle.jbo.Transaction
LOCK_NONE, LOCK_OPTIMISTIC, LOCK_PESSIMISTIC
 
Constructor Summary
DBTransactionImpl2()
           
 
Method Summary
TypeMethod
 void connect(java.sql.Connection sqlConnection)
          Uses this JDBC Connection object to connect to the database for all operations via this transaction.
 void connect(java.lang.String url)
          Uses this JDBC Connection object to connect to the database for all operations via this transaction.
 void connect(java.lang.String url, java.util.Properties info)
          Internal: Applications should not use this method.
 void connect(java.lang.String url, java.lang.String user, java.lang.String password)
          Internal: Applications should not use this method.
 void connectToDataSource(javax.sql.DataSource ds, boolean isJTAbased)
           
 void connectToDataSource(javax.sql.DataSource ds, java.lang.String user, java.lang.String passwd, boolean isJTAbased)
           
 void connectToDataSource(java.util.Hashtable env, java.lang.String dsName, boolean isJTABased)
          Looks up a datasource from a jndi tree and acquires the jdbc connection from the looked up datasource using the javax.sql.Datasource.getConnection(String user, String passwd) method.
 void connectToDataSource(java.util.Hashtable env, java.lang.String dsName, java.lang.String user, java.lang.String passwd, boolean isJTABased)
          Looks up a datasource from a jndi tree and acquires the jdbc connection from the looked up datasource using the javax.sql.Datasource.getConnection(String user, String passwd) method.
 void connectToDataSource(java.lang.String nsUrl, java.lang.String nsUser, java.lang.String nsPasswd, java.lang.String dsUrl)
          Looks up a datasource from Oracle 8i namespace using the jdbc_access protocol and acquires the default jdbc connection from the looked up datasource using the javax.sql.Datasource.getConnection() method.
 void connectToDataSource(java.lang.String nsUrl, java.lang.String nsUser, java.lang.String nsPasswd, java.lang.String dsUrl, java.lang.String user, java.lang.String passwd)
          Looks up a datasource from Oracle 8i namespace using the jdbc_access protocol and acquires the jdbc connection from the looked up datasource using the javax.sql.Datasource.getConnection(String user, String password) method.
 java.sql.CallableStatement createCallableStatement(java.lang.String str, int noRowsPrefetch)
          Creates a JDBC CallableStatement instance.
 EntityImpl createEntityInstance(EntityDefImpl entityDef, AttributeList al)
          Creates an EntityImpl object based on the given defintion, in the context of the root Application Module.
 EntityImpl createEntityInstance(java.lang.String entityDefName, AttributeList al)
          Creates an EntityImpl object based on the given defintion, in the context of the root Application Module.
 java.sql.PreparedStatement createPreparedStatement(java.lang.String str, int noRowsPrefetch)
          Creates a JDBC PreparedStatement instance.
 java.lang.Object createRef(java.lang.String structName, byte[] data)
          Internal: Applications should not use this method.
 java.sql.Statement createStatement(int noRowsPrefetch)
          Creates a JDBC Statement instance.
 ViewObject createViewObjectFromQueryClauses(java.lang.String eoName, java.lang.String selectClause, java.lang.String fromClause, java.lang.String whereClause, java.lang.String orderByClause)
          Creates an updatable query definition.
 ViewObject createViewObjectFromQueryStmt(java.lang.String sqlStatement)
          Creates an anonymous query definition from an SQL statement.
 void disconnect(boolean retainState)
          Closes the JDBC connection object.
 EntityImpl findByPrimaryKey(EntityDefImpl entityDef, Key key)
          Finds an Entity Object in this transaction given an EntityDef object and a Primary Key.
 EntityImpl findByPrimaryKey(java.lang.String entityDefName, Key key)
          Finds an Entity Object in this transaction given the String name of the EntityDef and a Primary Key.
 void reconnect()
          Reconnect the ApplicationModule to the database, using previously supplied database credentials.
 void reconnect(boolean force)
          Reconnect the Application Module to the database, if necessary, using previously supplied database credentials.
 
Methods inherited from class oracle.jbo.server.DBTransactionImpl
addToValidationListeners, addTransactionListener, addTransactionListenerNoCheck, addTransactionPostListener, addTransactionPostListenerNoCheck, addTransactionStateListener, addViewClearCacheListener, addWarning, applyChangeSet, checkConnected, clearEntityCache, closeTransaction, commit, commitAndSaveChangeSet, createApplicationModule, createApplicationModule, createViewLink, createViewLinkBetweenViewObjects, createViewLinkFromEntityAssocName, createViewObject, disconnect, doCommit, doRollback, dumpEntityCaches, dumpQueryResult, executeCommand, findApplicationModule, getBatchPostExceptionThreshold, getConnectionMetadata, getJdbcConnection, getLockingMode, getPersistManagerConnection, getPostThreshold, getRootApplicationModule, getSession, getSQLBuilder, getTransactionHandler, getTransactionState, getTxnApplicationModuleImpl, getValidationThreshold, isBundledExceptionMode, isClearCacheOnCommit, isClearCacheOnRollback, isConnected, isConnected, isDirty, isTrackNewAndModifiedRowsOnly, postChanges, postChanges, removeChangeSet, removeTransactionListener, removeTransactionPostListener, removeTransactionStateListener, removeViewClearCacheListener, rollback, setBatchModeForEntity, setBatchPostExceptionThreshold, setBundledExceptionMode, setClearCacheOnCommit, setClearCacheOnRollback, setLockingMode, setPostThreshold, setTrackNewAndModifiedRowsOnly, setTransactionHandler, setValidationThreshold, showCursorUsage, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBTransactionImpl2

public DBTransactionImpl2()
Method Detail

connect

public void connect(java.sql.Connection sqlConnection)
Description copied from class: DBTransactionImpl
Uses this JDBC Connection object to connect to the database for all operations via this transaction. ApplicationModule calls this method on the transaction object. Internal: Applications should not use this method.
Overrides:
connect in class DBTransactionImpl

connect

public void connect(java.lang.String url)
Description copied from class: DBTransactionImpl
Uses this JDBC Connection object to connect to the database for all operations via this transaction. ApplicationModule calls this method on the transaction object. Internal: Applications should not use this method.

Use the connect method on the Transaction interface instead.

Overrides:
connect in class DBTransactionImpl
Following copied from interface: oracle.jbo.Transaction
Parameters:
url - a database url of the form jdbc:subprotocol:subname.

connect

public void connect(java.lang.String url,
                    java.util.Properties info)
Internal: Applications should not use this method.

Use the connect method on the Transaction interface instead.

Overrides:
connect in class DBTransactionImpl
Following copied from interface: oracle.jbo.Transaction
Parameters:
url - a database url of the form jdbc:subprotocol:subname.
info - a list of arbitrary string tag/value pairs to be used as connection arguments. Normally, at least "user" and "password" properties should be included.

connect

public void connect(java.lang.String url,
                    java.lang.String user,
                    java.lang.String password)
Internal: Applications should not use this method.

Use the connect method on the Transaction interface instead.

Overrides:
connect in class DBTransactionImpl
Following copied from interface: oracle.jbo.Transaction
Parameters:
url - a database url of the form jdbc:subprotocol:subname.
user - the database user on whose behalf the connection is being made.
password - the user's password.

connectToDataSource

public void connectToDataSource(java.lang.String nsUrl,
                                java.lang.String nsUser,
                                java.lang.String nsPasswd,
                                java.lang.String dsUrl)
Description copied from interface: Transaction
Looks up a datasource from Oracle 8i namespace using the jdbc_access protocol and acquires the default jdbc connection from the looked up datasource using the javax.sql.Datasource.getConnection() method.

Overrides:
connectToDataSource in class DBTransactionImpl
Following copied from interface: oracle.jbo.Transaction
Parameters:
nsUrl - Url to the jndi namespace where the datasource is bound
nsUser - User name that is used to access the namespace.
nsPasswd - nsUsers' passwd
datasourceName - Datasource name as bound in the namespace. Name can be the fully qaultified url such as jdbc_access://test/ds/db1 otherwise the the url prefix jdbc_acess:// is prepended to the datasource name for lookup.

connectToDataSource

public void connectToDataSource(java.lang.String nsUrl,
                                java.lang.String nsUser,
                                java.lang.String nsPasswd,
                                java.lang.String dsUrl,
                                java.lang.String user,
                                java.lang.String passwd)
Description copied from interface: Transaction
Looks up a datasource from Oracle 8i namespace using the jdbc_access protocol and acquires the jdbc connection from the looked up datasource using the javax.sql.Datasource.getConnection(String user, String password) method.

Overrides:
connectToDataSource in class DBTransactionImpl
Following copied from interface: oracle.jbo.Transaction
Parameters:
nsUrl - Url to the jndi namespace where the datasource is bound
nsUser - User name that is used to access the namespace.
nsPasswd - nsUsers' passwd
datasourceName - Datasource name as bound in the namespace. Name can be the fully qaultified url such as jdbc_access://test/ds/db1 otherwise the the url prefix jdbc_acess:// is prepended to the datasource name for lookup.
user - Username for which the connection is acquired from the datasource
password - User's password.

connectToDataSource

public void connectToDataSource(javax.sql.DataSource ds,
                                boolean isJTAbased)
Overrides:
connectToDataSource in class DBTransactionImpl

connectToDataSource

public void connectToDataSource(javax.sql.DataSource ds,
                                java.lang.String user,
                                java.lang.String passwd,
                                boolean isJTAbased)
Overrides:
connectToDataSource in class DBTransactionImpl

connectToDataSource

public void connectToDataSource(java.util.Hashtable env,
                                java.lang.String dsName,
                                java.lang.String user,
                                java.lang.String passwd,
                                boolean isJTABased)
Description copied from interface: Transaction
Looks up a datasource from a jndi tree and acquires the jdbc connection from the looked up datasource using the javax.sql.Datasource.getConnection(String user, String passwd) method.

Overrides:
connectToDataSource in class DBTransactionImpl
Following copied from interface: oracle.jbo.Transaction
Parameters:
initialContextEnv - Envirionment used the create initial context. May be null.
datasourceName - Datasource name as bound in the namespace.
user - Username for which the connection is acquired from the datasource
password - User's password.
isXABased - True if datasource is XADataSource implementation. If true, the tranasction is assumed to be controlled by an external transaction manager.

connectToDataSource

public void connectToDataSource(java.util.Hashtable env,
                                java.lang.String dsName,
                                boolean isJTABased)
Description copied from interface: Transaction
Looks up a datasource from a jndi tree and acquires the jdbc connection from the looked up datasource using the javax.sql.Datasource.getConnection(String user, String passwd) method.

Overrides:
connectToDataSource in class DBTransactionImpl
Following copied from interface: oracle.jbo.Transaction
Parameters:
initialContextEnv - Envirionment used the create initial context. May be null.
datasourceName - Datasource name as bound in the namespace.
isXABased - True if datasource is XADataSource implementation. If true, the tranasction is assumed to be controlled by an external transaction manager.

disconnect

public void disconnect(boolean retainState)
Description copied from class: DBTransactionImpl
Closes the JDBC connection object. If disconnect is invoked with retainState equal to false then the JDBC connection will be closed and this transaction will be removed* from the root application module.

If disconnect is invoked with retainState equal to true then this transaction's JDBC connection will be closed but, the root application module will continue to reference this transaction and its state. The transaction state may include unposted database changes and cached result sets. In the middle tier, reconnect on the DBTransaction interface may be invoked to re-establish a JDBC connection for this transaction. If connection pooling is enabled for this middle tier instance this connection may represent a recycled connection.

The developer should take measures to ensure that the following requirements are met before attempting to disconnect a JDBC connection and retain application module state. All of these validations are not currently performed by the disconnection implementation because of performance considerations:

All non-forward only view objects should have fetched in all data

If pessimistic locking is enabled, all pending changes should be commited/rolled back.

All changes that have been posted to the database should be commited/rolled back>/p>

Overrides:
disconnect in class DBTransactionImpl

reconnect

public void reconnect()
Description copied from class: DBTransactionImpl
Reconnect the ApplicationModule to the database, using previously supplied database credentials. This method should only be invoked if the transaction has been previously disconnected using DBTransactionImpl.disconnect(boolean) with the retainState parameter equal to true or, if a previous isConnected() request had discovered a stale JDBC connection. If it is invoked otherwise the method will do nothing.
Overrides:
reconnect in class DBTransactionImpl
Following copied from class: oracle.jbo.server.DBTransactionImpl
See Also:
DBTransactionImpl.disconnect(boolean)

reconnect

public void reconnect(boolean force)
Reconnect the Application Module to the database, if necessary, using previously supplied database credentials. If the parameter is true, then a database disconnect and reconnect is performed, whatever the current connection state. If false, the connect is only performed if the connection has disappeared.
Overrides:
reconnect in class DBTransactionImpl
Parameters:
force - force a reconnect, should usually be false.

createStatement

public java.sql.Statement createStatement(int noRowsPrefetch)
Description copied from interface: DBTransaction
Creates a JDBC Statement instance.

Applications may use this method to create a JDBC statement object to execute application specific SQL statements directly, so that the modifications are committed to the database in a single transaction through this object.

Overrides:
createStatement in class DBTransactionImpl
Following copied from interface: oracle.jbo.server.DBTransaction
Parameters:
noRowsPrefetch - the number of rows to prefetch when executing this statement's query.
Returns:
a JDBC Statement instance.

createCallableStatement

public java.sql.CallableStatement createCallableStatement(java.lang.String str,
                                                          int noRowsPrefetch)
Description copied from interface: DBTransaction
Creates a JDBC CallableStatement instance.

Applications may use this method to create a JDBC callable statement object to execute application-specific SQL statements directly, so that the modifications are committed to the database in a single transaction through this object.

Overrides:
createCallableStatement in class DBTransactionImpl
Following copied from interface: oracle.jbo.server.DBTransaction
Parameters:
str - the CallableStatement 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 CallableStatement instance.

createPreparedStatement

public java.sql.PreparedStatement createPreparedStatement(java.lang.String str,
                                                          int noRowsPrefetch)
Description copied from interface: DBTransaction
Creates a JDBC PreparedStatement instance.

Applications may use this method to create a JDBC callable statement object to execute application specific SQL statements directly, so that the modifications are committed to the database in a single transaction through this object.

Overrides:
createPreparedStatement in class DBTransactionImpl
Following copied from interface: oracle.jbo.server.DBTransaction
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.

createEntityInstance

public EntityImpl createEntityInstance(EntityDefImpl entityDef,
                                       AttributeList al)
Description copied from class: DBTransactionImpl
Creates an EntityImpl object based on the given defintion, in the context of the root Application Module. Passes the attribute list, al, to the create method on the EntityImpl.
Overrides:
createEntityInstance in class DBTransactionImpl
Following copied from class: oracle.jbo.server.DBTransactionImpl
Parameters:
entityDef - the EntityDef defintion to use to create the EntityImpl.
al - attribute list to pass to the create() method on the EntityImpl.

createEntityInstance

public EntityImpl createEntityInstance(java.lang.String entityDefName,
                                       AttributeList al)
Description copied from class: DBTransactionImpl
Creates an EntityImpl object based on the given defintion, in the context of the root Application Module. Passes the attribute list, al, to the create method on the EntityImpl.
Overrides:
createEntityInstance in class DBTransactionImpl
Following copied from class: oracle.jbo.server.DBTransactionImpl
Parameters:
entityDefName - the String name of entity defintion to use to create the EntityImpl.
al - attribute list to pass to the create method on the EntityImpl.

findByPrimaryKey

public EntityImpl findByPrimaryKey(EntityDefImpl entityDef,
                                   Key key)
Description copied from class: DBTransactionImpl
Finds an Entity Object in this transaction given an EntityDef object and a Primary Key.

Given the EntityDef object and the table's primary key, this method returns the associated Entity Object. If the Entity has not already been brought into the cache by any of the View Objects, this method will cause the Entity to be fetched from the database. This method returns null if the Entity Object is not found.

For example, use this method to create a set of Entity Objects based on a relational schema without the need to create any Application Modules or View Objects. To do this, use findByPrimaryKey to locate a specific object and then traverse association accessors to get to all the other objects.

Overrides:
findByPrimaryKey in class DBTransactionImpl
Following copied from class: oracle.jbo.server.DBTransactionImpl
Parameters:
entityDef - the Entity Def object to to be used to find the instance.
key - the Primary Key.
Returns:
the Entity Object matching Key, or null if not found.

findByPrimaryKey

public EntityImpl findByPrimaryKey(java.lang.String entityDefName,
                                   Key key)
Description copied from class: DBTransactionImpl
Finds an Entity Object in this transaction given the String name of the EntityDef and a Primary Key.

Given the String name of the EntityDef and the table's primary key, this method returns the associated Entity Object. If the Entity has not already been brought into the cache by any of the View Objects, this method will cause the Entity to be fetched from the database.

This method returns null if the Entity Object is not found.

For example, use this method to create a set of Entity Objects based on a relational schema without the need to create any Application Modules or View Objects. To do this, use findByPrimaryKey to locate a specific object and then traverse association accessors to get to all the other objects.

Overrides:
findByPrimaryKey in class DBTransactionImpl
Following copied from class: oracle.jbo.server.DBTransactionImpl
Parameters:
entityDefName - the name of the defintion to to be used to find the instance.
key - the Primary Key.
Returns:
the Entity Object matching Key, or null if not found.

createViewObjectFromQueryClauses

public ViewObject createViewObjectFromQueryClauses(java.lang.String eoName,
                                                   java.lang.String selectClause,
                                                   java.lang.String fromClause,
                                                   java.lang.String whereClause,
                                                   java.lang.String orderByClause)
Description copied from class: DBTransactionImpl
Creates an updatable query definition.

Creates an anonymous query definition from an Entity Object and parts of a SQL statement. For more information on anonymous View Objects, see Using Anonymous View Objects

Calling method should also call remove() for the View Object to be properly garbage-collected.

Overrides:
createViewObjectFromQueryClauses in class DBTransactionImpl
Following copied from class: oracle.jbo.server.DBTransactionImpl
Parameters:
eoName - the name of a EntityObject beaninfo class.
selectClause - an SQL statement SELECT clause.
fromClause - an SQL statement FROM clause.
whereClause - an SQL statement WHERE clause.
orderbyClause - an SQL statement ORDERBY clause.

createViewObjectFromQueryStmt

public ViewObject createViewObjectFromQueryStmt(java.lang.String sqlStatement)
Description copied from class: DBTransactionImpl
Creates an anonymous query definition from an SQL statement. For more information on anonymous View Objects, see Using Anonymous View Objects

Calling method should also call remove() for the View Object to be properly garbage-collected.

The following example creates a View Object that queries for the system date:

  ViewObject vo = tx.createViewObjectFromQueryStmt("select sysdate
   from dual");
         Row row = vo.first();
         Date now = (Date) row.getAttribute(0);
         System.out.println("The date/time is now: "+now);
         oracle.sql.DATE nextMonth = now.addMonths(1);
         System.out.println("The date/time is now: "+nextMonth);
 
Overrides:
createViewObjectFromQueryStmt in class DBTransactionImpl
Following copied from class: oracle.jbo.server.DBTransactionImpl
Parameters:
sqlStatement - a SQL statement.

createRef

public java.lang.Object createRef(java.lang.String structName,
                                  byte[] data)
Description copied from class: DBTransactionImpl
Internal: Applications should not use this method.
Overrides:
createRef in class DBTransactionImpl

Business Components