Business Components

oracle.jbo.server
Class OracleSQLBuilderImpl

java.lang.Object
  |
  +--oracle.jbo.server.OracleSQLBuilderImpl

public class OracleSQLBuilderImpl
extends java.lang.Object
implements SQLBuilder

Oracle-specific implementation of the SQLBuilder interface.

Since:
JDeveloper 3.0

Field Summary
protected static java.lang.String ORACLE_ROWID_COLUMN
           
 
Fields inherited from interface oracle.jbo.server.SQLBuilder
BINDING_STYLE_JDBC, BINDING_STYLE_ORACLE, BINDING_STYLE_UNKNOWN, DML_DELETE, DML_INSERT, DML_UPDATE
 
Constructor Summary
protected OracleSQLBuilderImpl()
          This is a singleton class
 
Method Summary
protected static java.lang.String addSqlTypeText(java.lang.String sqlText, java.lang.String inputType)
          helper for getTableList
protected  java.lang.StringBuffer buildDeleteStatement(EntityImpl entityContext, java.lang.String sinkName, java.lang.String sinkAlias, AttributeDefImpl[] keyCols)
          Construct a SQL INSERT statement
protected  java.lang.StringBuffer buildInsertStatement(EntityImpl entityContext, java.lang.String sinkName, java.lang.String sinkAlias, AttributeDefImpl[] cols, AttributeDefImpl[] keyCols, AttributeDefImpl[] retrCols, AttributeDefImpl[] retrKeyCols)
          Construct a SQL INSERT statement
protected  void buildSelectString(java.lang.StringBuffer buffer, java.lang.String sourceName, java.lang.String sourceAlias, AttributeDefImpl[] attrs, boolean withIntoClause, int bindingStyle)
          Construct a SQL SELECT statement for the Entity into the designated Buffer.
protected  java.lang.StringBuffer buildUpdateStatement(EntityImpl entityContext, java.lang.String sinkName, java.lang.String sinkAlias, AttributeDefImpl[] cols, AttributeDefImpl[] keyCols, AttributeDefImpl[] retrCols, AttributeDefImpl[] retrKeyCols)
          DOCTD: Method declaration TODO: KM _ don't like the fact that this requires an entitydef
protected  void buildWhereClause(EntityImpl entityContext, java.lang.StringBuffer buffer, AttributeDefImpl[] keyCols, java.lang.Object rowid)
          Construct a SQL WHERE clause for the Entity into the designated Buffer, based upon the Source Columns.
 void doEntityDML(EntityImpl entityContext, int operation, TransactionEvent e)
          Performs the appropriate SQL Data Manipulation Language (DML) operations on the database to reflect an update, delete or insert operation on an Entity Object.
 void doEntitySelect(EntityImpl entityContext, boolean lock)
          Perform the appropriate SQL operations to execute a select operation on an Entity Object.
 java.lang.Object[] doLoadBulkFromResultSet(AttributeDefImpl[] attrDefs, int attrIndex, java.sql.ResultSet rs, int index, DBTransactionImpl trans)
          Loads an array of objects from a result set.
 java.lang.Object doLoadFromResultSet(java.lang.Object theTypeFactory, java.lang.Object theElemFactory, java.lang.Class theJavaType, byte attrLoad, java.sql.ResultSet rs, int index, DBTransactionImpl trans)
          Loads an object from a result set.
 java.lang.Object doLoadFromStatement(java.lang.Object theTypeFactory, java.lang.Object theElemFactory, java.lang.Class theJavaType, java.sql.PreparedStatement ps, int index, Transaction trans)
          Loads an object from a result set.
 void doPreparedStatementDefineColumnType(java.sql.PreparedStatement ps, int colnum, int sqltype)
          Performs the equivalent of defineColumnType() on a prepared statement.
 void doPreparedStatementDefines(java.sql.PreparedStatement stmt, AttributeDefImpl[] columns)
          Performs the equivalent of clearDefines() on a prepared statement.
 void doRegisterDefaultDriver()
          Registers the JDBC driver associated with this type of JDBC connection.
 void doStatementSetBindingStyle(java.sql.Statement ps, int bindingStyle)
          Sets the binding style for the statement.
 void doStatementSetBindingStyleDefault(java.sql.Statement ps)
           
 void doStatementSetRowPrefetch(java.sql.Statement ps, int prefetchSize)
          Performs the equivalent of setRowPrefetch() on a statement.
 java.lang.Object generatePKBasedRef(EntityImpl entityContext)
          Generates a PK-Based REF for an Entity Object.
 java.lang.Object[] generateRefAndOID(EntityImpl entityContext)
          Generates an object Ref and OID for an Entity Object.
 java.lang.Object generateRowID(EntityImpl entityContext)
          Generates a ROWID for an Entity Object.
 java.lang.String getBaseTable(java.sql.Connection conn, java.lang.String schema, java.lang.String name)
          unroll any synonyms that may be present, and get the real objectname
 java.sql.ResultSet getConstraints(java.sql.Connection conn, java.lang.String catalog, java.lang.String schema, java.lang.String table)
          return a resultset with constarint details: TODO: for 4.0 reshape this call - which is listed verbatim from jbo.dt.utils.JboDBUtil
 java.lang.String getDbType()
          returns a string uniquely identifying this type of SQLBuilder.
 int getDefaultBindingStyle()
          returns a constant identifying the best binding style for this sort of SQL (see the BINDINGSTYLE constants)
static SQLBuilder getInterface()
          Gets the singleton instance of this class.
 java.util.Vector getTableList(java.sql.Connection conn, java.lang.String defaultUserName, java.lang.String userName, boolean bTable, boolean bAlias, boolean bView, boolean bSnap)
          return a list of tables visible in this connection
protected static java.lang.String getTableListSqlStatement(java.lang.String defaultUserName, java.lang.String userName, boolean bTable, boolean bAlias, boolean bView, boolean bSnap, boolean bCount)
          helper for getTableList
 java.lang.String getVersion()
          Gets a string describing the version of this implentation of this interface.
 boolean isNumericType(int type)
          Tests if a type is numeric.
 boolean isStreamType(int sqlTypeId)
          Provides streaming support.
 void populateJboTypeMapEntries()
          Populates the system typemap table with entries appropriate for the JDBC implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ORACLE_ROWID_COLUMN

protected static final java.lang.String ORACLE_ROWID_COLUMN
Constructor Detail

OracleSQLBuilderImpl

protected OracleSQLBuilderImpl()
This is a singleton class
Method Detail

getInterface

public static SQLBuilder getInterface()
Gets the singleton instance of this class.

getVersion

public java.lang.String getVersion()
Description copied from interface: SQLBuilder
Gets a string describing the version of this implentation of this interface.
Specified by:
getVersion in interface SQLBuilder

getDbType

public java.lang.String getDbType()
Description copied from interface: SQLBuilder
returns a string uniquely identifying this type of SQLBuilder. Examples are: "Oracle" and "OLite"
Specified by:
getDbType in interface SQLBuilder

getDefaultBindingStyle

public int getDefaultBindingStyle()
Description copied from interface: SQLBuilder
returns a constant identifying the best binding style for this sort of SQL (see the BINDINGSTYLE constants)
Specified by:
getDefaultBindingStyle in interface SQLBuilder

doEntityDML

public void doEntityDML(EntityImpl entityContext,
                        int operation,
                        TransactionEvent e)
Description copied from interface: SQLBuilder
Performs the appropriate SQL Data Manipulation Language (DML) operations on the database to reflect an update, delete or insert operation on an Entity Object.

Note: this method is subject to change.

Specified by:
doEntityDML in interface SQLBuilder
Tags copied from interface: SQLBuilder
Parameters:
enrt - the Entity Object.
operation - one of DML_INSERT, DML_UPDATE, or DML_DELETE.
e - the transaction.

doEntitySelect

public void doEntitySelect(EntityImpl entityContext,
                           boolean lock)
Description copied from interface: SQLBuilder
Perform the appropriate SQL operations to execute a select operation on an Entity Object.

Note: this method is subject to change.

Specified by:
doEntitySelect in interface SQLBuilder
Tags copied from interface: SQLBuilder
Parameters:
enrt - the Entity Object.
lock - if true, a "SELECT for UPDATE" statement is used.

generateRowID

public java.lang.Object generateRowID(EntityImpl entityContext)
Description copied from interface: SQLBuilder
Generates a ROWID for an Entity Object.

Specified by:
generateRowID in interface SQLBuilder

doStatementSetRowPrefetch

public void doStatementSetRowPrefetch(java.sql.Statement ps,
                                      int prefetchSize)
                               throws java.sql.SQLException
Description copied from interface: SQLBuilder
Performs the equivalent of setRowPrefetch() on a statement.
Specified by:
doStatementSetRowPrefetch in interface SQLBuilder

doStatementSetBindingStyle

public void doStatementSetBindingStyle(java.sql.Statement ps,
                                       int bindingStyle)
Description copied from interface: SQLBuilder
Sets the binding style for the statement.
Specified by:
doStatementSetBindingStyle in interface SQLBuilder

doStatementSetBindingStyleDefault

public void doStatementSetBindingStyleDefault(java.sql.Statement ps)
Specified by:
doStatementSetBindingStyleDefault in interface SQLBuilder

doPreparedStatementDefineColumnType

public void doPreparedStatementDefineColumnType(java.sql.PreparedStatement ps,
                                                int colnum,
                                                int sqltype)
                                         throws java.sql.SQLException
Description copied from interface: SQLBuilder
Performs the equivalent of defineColumnType() on a prepared statement.
Specified by:
doPreparedStatementDefineColumnType in interface SQLBuilder

doPreparedStatementDefines

public void doPreparedStatementDefines(java.sql.PreparedStatement stmt,
                                       AttributeDefImpl[] columns)
Description copied from interface: SQLBuilder
Performs the equivalent of clearDefines() on a prepared statement.
Specified by:
doPreparedStatementDefines in interface SQLBuilder

doRegisterDefaultDriver

public void doRegisterDefaultDriver()
                             throws java.sql.SQLException
Description copied from interface: SQLBuilder
Registers the JDBC driver associated with this type of JDBC connection.
Specified by:
doRegisterDefaultDriver in interface SQLBuilder
Tags copied from interface: SQLBuilder
Throws:
java.sql.SQLException -  

populateJboTypeMapEntries

public void populateJboTypeMapEntries()
Description copied from interface: SQLBuilder
Populates the system typemap table with entries appropriate for the JDBC implementation.
Specified by:
populateJboTypeMapEntries in interface SQLBuilder

isNumericType

public boolean isNumericType(int type)
Description copied from interface: SQLBuilder
Tests if a type is numeric.
Specified by:
isNumericType in interface SQLBuilder

doLoadFromResultSet

public java.lang.Object doLoadFromResultSet(java.lang.Object theTypeFactory,
                                            java.lang.Object theElemFactory,
                                            java.lang.Class theJavaType,
                                            byte attrLoad,
                                            java.sql.ResultSet rs,
                                            int index,
                                            DBTransactionImpl trans)
Description copied from interface: SQLBuilder
Loads an object from a result set.

Note: this method is subject to change.

Specified by:
doLoadFromResultSet in interface SQLBuilder
Tags copied from interface: SQLBuilder
Parameters:
theTypeFactory - a custom factory to be used for constructing new instances.
index - the index of the object to be loaded.

doLoadBulkFromResultSet

public java.lang.Object[] doLoadBulkFromResultSet(AttributeDefImpl[] attrDefs,
                                                  int attrIndex,
                                                  java.sql.ResultSet rs,
                                                  int index,
                                                  DBTransactionImpl trans)
Description copied from interface: SQLBuilder
Loads an array of objects from a result set.

Note: this method is subject to change.

Specified by:
doLoadBulkFromResultSet in interface SQLBuilder
Tags copied from interface: SQLBuilder
Parameters:
index - the index of the object to be loaded.

doLoadFromStatement

public java.lang.Object doLoadFromStatement(java.lang.Object theTypeFactory,
                                            java.lang.Object theElemFactory,
                                            java.lang.Class theJavaType,
                                            java.sql.PreparedStatement ps,
                                            int index,
                                            Transaction trans)
Description copied from interface: SQLBuilder
Loads an object from a result set.

Note: this method is subject to change.

Specified by:
doLoadFromStatement in interface SQLBuilder
Tags copied from interface: SQLBuilder
Parameters:
theTypeFactory - a custom factory to be used for constructing new instances.
index - the index of the object to be loaded.

buildUpdateStatement

protected java.lang.StringBuffer buildUpdateStatement(EntityImpl entityContext,
                                                      java.lang.String sinkName,
                                                      java.lang.String sinkAlias,
                                                      AttributeDefImpl[] cols,
                                                      AttributeDefImpl[] keyCols,
                                                      AttributeDefImpl[] retrCols,
                                                      AttributeDefImpl[] retrKeyCols)
DOCTD: Method declaration TODO: KM _ don't like the fact that this requires an entitydef
Parameters:
sinkName -  
cols -  
keyCols -  
retrCols -  
retrKeyCols -  
Returns:
 

buildWhereClause

protected void buildWhereClause(EntityImpl entityContext,
                                java.lang.StringBuffer buffer,
                                AttributeDefImpl[] keyCols,
                                java.lang.Object rowid)
Construct a SQL WHERE clause for the Entity into the designated Buffer, based upon the Source Columns. This routine will construct a SQL WHERE clause in the StringBuffer passed. It does this by appending the various components of the WHERE Clause (based upon Primary Key columns) into the buffer area.

For now it's private. We'll only consider it public when we sort out all of the issues with Sources/Sinks.

The presence or absence of the ROWID value determines whether the ROWID will be used for Row access.

Parameters:
buffer - the area into which the WHERE Clause will be placed.
keyCols - the Primary key columns.
rowid - the ROWID for the ROW if known.

buildInsertStatement

protected java.lang.StringBuffer buildInsertStatement(EntityImpl entityContext,
                                                      java.lang.String sinkName,
                                                      java.lang.String sinkAlias,
                                                      AttributeDefImpl[] cols,
                                                      AttributeDefImpl[] keyCols,
                                                      AttributeDefImpl[] retrCols,
                                                      AttributeDefImpl[] retrKeyCols)
Construct a SQL INSERT statement
Parameters:
-  

buildDeleteStatement

protected java.lang.StringBuffer buildDeleteStatement(EntityImpl entityContext,
                                                      java.lang.String sinkName,
                                                      java.lang.String sinkAlias,
                                                      AttributeDefImpl[] keyCols)
Construct a SQL INSERT statement
Parameters:
-  

buildSelectString

protected void buildSelectString(java.lang.StringBuffer buffer,
                                 java.lang.String sourceName,
                                 java.lang.String sourceAlias,
                                 AttributeDefImpl[] attrs,
                                 boolean withIntoClause,
                                 int bindingStyle)
Construct a SQL SELECT statement for the Entity into the designated Buffer. This routine will construct a SQL SELECT statement in the StringBuffer passed. It does this by appending the various components of the SELECT statement into the buffer area.

Parameters:
buffer - the area into which the SELECT statement will be placed.

generatePKBasedRef

public java.lang.Object generatePKBasedRef(EntityImpl entityContext)
Description copied from interface: SQLBuilder
Generates a PK-Based REF for an Entity Object. This is used for an object table.
Specified by:
generatePKBasedRef in interface SQLBuilder

generateRefAndOID

public java.lang.Object[] generateRefAndOID(EntityImpl entityContext)
Description copied from interface: SQLBuilder
Generates an object Ref and OID for an Entity Object. This is used for an object table.
Specified by:
generateRefAndOID in interface SQLBuilder

isStreamType

public boolean isStreamType(int sqlTypeId)
Description copied from interface: SQLBuilder
Provides streaming support.
Specified by:
isStreamType in interface SQLBuilder

getTableList

public java.util.Vector getTableList(java.sql.Connection conn,
                                     java.lang.String defaultUserName,
                                     java.lang.String userName,
                                     boolean bTable,
                                     boolean bAlias,
                                     boolean bView,
                                     boolean bSnap)
                              throws java.lang.Exception
Description copied from interface: SQLBuilder
return a list of tables visible in this connection
Specified by:
getTableList in interface SQLBuilder

getTableListSqlStatement

protected static java.lang.String getTableListSqlStatement(java.lang.String defaultUserName,
                                                           java.lang.String userName,
                                                           boolean bTable,
                                                           boolean bAlias,
                                                           boolean bView,
                                                           boolean bSnap,
                                                           boolean bCount)
helper for getTableList

addSqlTypeText

protected static java.lang.String addSqlTypeText(java.lang.String sqlText,
                                                 java.lang.String inputType)
helper for getTableList

getConstraints

public java.sql.ResultSet getConstraints(java.sql.Connection conn,
                                         java.lang.String catalog,
                                         java.lang.String schema,
                                         java.lang.String table)
                                  throws java.sql.SQLException
Description copied from interface: SQLBuilder
return a resultset with constarint details: TODO: for 4.0 reshape this call - which is listed verbatim from jbo.dt.utils.JboDBUtil
Specified by:
getConstraints in interface SQLBuilder

getBaseTable

public java.lang.String getBaseTable(java.sql.Connection conn,
                                     java.lang.String schema,
                                     java.lang.String name)
                              throws java.sql.SQLException
Description copied from interface: SQLBuilder
unroll any synonyms that may be present, and get the real objectname
Specified by:
getBaseTable in interface SQLBuilder

Business Components