Business Components

oracle.jbo.server
Class OracleSQLBuilderImpl

java.lang.Object
  |
  +--oracle.jbo.server.BaseSQLBuilderImpl
        |
        +--oracle.jbo.server.OracleSQLBuilderImpl
All Implemented Interfaces:
SQLBuilder, ViewCriteriaAdapter

public class OracleSQLBuilderImpl
extends BaseSQLBuilderImpl

Oracle-specific implementation of the SQLBuilder interface.

Since:
JDeveloper 3.0

Field Summary
TypeField
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
TypeConstructor
protected OracleSQLBuilderImpl()
          This is a singleton class
 
Method Summary
TypeMethod
protected static java.lang.String addSqlTypeText(java.lang.String sqlText, java.lang.String inputType)
          helper for getTableList
protected  int bindWhereClause(EntityImpl entityContext, java.sql.PreparedStatement stmt, AttributeDefImpl[] keyCols, java.lang.Object rowid, int bindIndex)
          Bind the Primary key values for the designated Statement.
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, boolean batchMode)
          Construct a SQL INSERT statement
protected  void buildSelectString(DBTransactionImpl trans, 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, boolean batchMode)
          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 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.
 void executeBatch(java.sql.PreparedStatement stmt)
           
 java.lang.Object generatePKBasedRef(EntityImpl entityContext)
          Initial (temporay) value for ROWID, so that entity can be added in cache TODO: this is an awkward piece of non-generic JDBC - not sure how to emulate rowids in the generic case
 java.lang.Object[] generateRefAndOID(EntityImpl entityContext)
          Generates an object Ref and OID 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
protected  java.lang.String getColumnNameWithFormatForQuery(java.lang.String colName, AttributeDef attrDef, int sqltype)
           
 com.sun.java.util.collections.ArrayList getConstraintsList(java.sql.Connection conn, java.lang.String catalog, java.lang.String schema, java.lang.String table)
          return vector of with constraint details for this table where each detail is in a String array with this structure: 0 String owner
 java.lang.String getDbType()
          returns a string uniquely identifying this type of SQLBuilder.
 int getDefaultBindingStyle()
          unless overridden, the binding style is set to JDBC (Oracle versions change this)
static SQLBuilder getInterface()
          Gets the singleton instance of this class.
protected  java.lang.String getJDBCDriverClassName()
          concrete implementations of SQLBuilder must elect a default driver name
 java.lang.String getPersistManagerClassName()
          Returns the name of default PersistManager class name.
protected  java.lang.Object getROWID(EntityImpl entityContext)
          Get the ROWID attribute.
 java.util.Vector getSchemaList(java.sql.Connection connection)
          return a list of schemas for this database (note that for Oracle this is synonymous with users)
protected  java.lang.String getSqlVariantLockTrailer()
          This defines the string that will be post-fixed to SQL ststements to have the rows locked - if the DB is incapable of this then is should return null.
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
 com.sun.java.util.collections.ArrayList getTables(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
 java.lang.String getTypeMapName()
          Returns a String identifying the preferred type map to use.
 java.lang.String getVersion()
          Gets a string describing the version of this implentation of this interface.
 boolean isDataSourceJTABased(javax.sql.DataSource ds)
           
 boolean isStreamType(int sqlTypeId)
          Provides streaming support.
 javax.sql.DataSource lookupDataSource(java.lang.String nsUrl, java.lang.String nsUser, java.lang.String nsPasswd, java.lang.String dataSourceName)
           
 void releaseSavePoint(java.sql.Connection conn, java.lang.String id)
           
 void rollbackToSavepoint(java.sql.Connection conn, java.lang.String id)
          rollback to SAVEPOINT - if possible
 void setSavepoint(java.sql.Connection conn, java.lang.String id)
          issue a SAVEPOINT - if possible
 
Methods inherited from class oracle.jbo.server.BaseSQLBuilderImpl
bindInsertStatement, bindUpdateStatement, buildInsertStatement, buildSelectString, buildUpdateStatement, capabilityCanReuseLockStatements, convertFlags, convertValueToWhereFragment, doRegisterDefaultDriver, dumpConstraint, generateRowID, getConstraints, getSchemas, getTableList, getViewCriteriaAdapter, getViewCriteriaClause, getWarningText, isCharType, isNumericType, populateJboTypeMapEntries, releaseSavepoint, shouldSkipDML
 
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.
Overrides:
getVersion in class BaseSQLBuilderImpl

getDbType

public java.lang.String getDbType()
Description copied from interface: SQLBuilder
returns a string uniquely identifying this type of SQLBuilder. Examples are: "Oracle", "OLite", "SQL92"
Overrides:
getDbType in class BaseSQLBuilderImpl

getTypeMapName

public java.lang.String getTypeMapName()
Description copied from interface: SQLBuilder
Returns a String identifying the preferred type map to use.
Overrides:
getTypeMapName in class BaseSQLBuilderImpl

getPersistManagerClassName

public java.lang.String getPersistManagerClassName()
Description copied from interface: SQLBuilder
Returns the name of default PersistManager class name.
Overrides:
getPersistManagerClassName in class BaseSQLBuilderImpl

getDefaultBindingStyle

public int getDefaultBindingStyle()
Description copied from class: BaseSQLBuilderImpl
unless overridden, the binding style is set to JDBC (Oracle versions change this)
Overrides:
getDefaultBindingStyle in class BaseSQLBuilderImpl

executeBatch

public void executeBatch(java.sql.PreparedStatement stmt)
                  throws java.sql.SQLException
Overrides:
executeBatch in class BaseSQLBuilderImpl

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.

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

Overrides:
doEntitySelect in class BaseSQLBuilderImpl
Following copied from interface: oracle.jbo.server.SQLBuilder
Parameters:
enrt - the Entity Object.
lock - if true, a "SELECT for UPDATE" statement is used.

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.
Overrides:
doStatementSetRowPrefetch in class BaseSQLBuilderImpl

doStatementSetBindingStyle

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

doStatementSetBindingStyleDefault

public void doStatementSetBindingStyleDefault(java.sql.Statement ps)
Overrides:
doStatementSetBindingStyleDefault in class BaseSQLBuilderImpl

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.
Overrides:
doPreparedStatementDefineColumnType in class BaseSQLBuilderImpl

doPreparedStatementDefines

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

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.

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

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

Overrides:
doLoadFromStatement in class BaseSQLBuilderImpl
Following copied from interface: oracle.jbo.server.SQLBuilder
Parameters:
theTypeFactory - a custom factory to be used for constructing new instances.
index - the index of the object to be loaded.

setSavepoint

public void setSavepoint(java.sql.Connection conn,
                         java.lang.String id)
                  throws java.sql.SQLException
Description copied from interface: SQLBuilder
issue a SAVEPOINT - if possible

Overrides:
setSavepoint in class BaseSQLBuilderImpl
Following copied from interface: oracle.jbo.server.SQLBuilder
Parameters:
id - = the id for a savepoint

rollbackToSavepoint

public void rollbackToSavepoint(java.sql.Connection conn,
                                java.lang.String id)
                         throws java.sql.SQLException
Description copied from interface: SQLBuilder
rollback to SAVEPOINT - if possible

Overrides:
rollbackToSavepoint in class BaseSQLBuilderImpl
Following copied from interface: oracle.jbo.server.SQLBuilder
Parameters:
id - = the id for a savepoint

releaseSavePoint

public void releaseSavePoint(java.sql.Connection conn,
                             java.lang.String id)
                      throws java.sql.SQLException

buildUpdateStatement

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

bindWhereClause

protected int bindWhereClause(EntityImpl entityContext,
                              java.sql.PreparedStatement stmt,
                              AttributeDefImpl[] keyCols,
                              java.lang.Object rowid,
                              int bindIndex)
                       throws java.sql.SQLException
Bind the Primary key values for the designated Statement. This routine will perform the bind operation for each of the Primary Key columns.

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.

Overrides:
bindWhereClause in class BaseSQLBuilderImpl
Parameters:
stmt - the statement to bind the columns to.
keyCols - the Primary key columns.
rowid - the ROWID for the ROW if known.
bindIndex - the baseline idx for performing the bind operations.

getROWID

protected java.lang.Object getROWID(EntityImpl entityContext)
Get the ROWID attribute. The ROWID attribute can be used to gain faster access to the underyling database data. Obtain the value for the ROWID attribute. If this entity doesn't support ROWID attributes, then return NULL. If, for some reason the value of the ROWID attribute isn't present, then return null.
Overrides:
getROWID in class BaseSQLBuilderImpl
Returns:
the value of the ROWID attribute or null if not present or applicable to this entity.

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.

Overrides:
buildWhereClause in class BaseSQLBuilderImpl
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,
                                                      boolean batchMode)
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
Overrides:
buildDeleteStatement in class BaseSQLBuilderImpl
Parameters:
-  

buildSelectString

protected void buildSelectString(DBTransactionImpl trans,
                                 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 class: BaseSQLBuilderImpl
Initial (temporay) value for ROWID, so that entity can be added in cache TODO: this is an awkward piece of non-generic JDBC - not sure how to emulate rowids in the generic case
Overrides:
generatePKBasedRef in class BaseSQLBuilderImpl

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.
Overrides:
generateRefAndOID in class BaseSQLBuilderImpl

isStreamType

public boolean isStreamType(int sqlTypeId)
Description copied from interface: SQLBuilder
Provides streaming support.
Overrides:
isStreamType in class BaseSQLBuilderImpl

getSchemaList

public java.util.Vector getSchemaList(java.sql.Connection connection)
                               throws java.lang.Exception
return a list of schemas for this database (note that for Oracle this is synonymous with users)
Overrides:
getSchemaList in class BaseSQLBuilderImpl

getTables

public com.sun.java.util.collections.ArrayList getTables(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
Overrides:
getTables in class BaseSQLBuilderImpl

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

getConstraintsList

public com.sun.java.util.collections.ArrayList getConstraintsList(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 vector of with constraint details for this table where each detail is in a String array with this structure: 0 String owner

1 String constraint_name

2 String constraint_type

3 String table_name

4 String search_condition

5 Integer delete_rule (cascade)

6 Integer status (enabled)

7 Integerdeferrable

8 Integer deferred

9 Integer validated

10 String column_name

11 Integer position

12 String fkname

13 String fkother <>

Overrides:
getConstraintsList in class BaseSQLBuilderImpl

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
Overrides:
getBaseTable in class BaseSQLBuilderImpl

getJDBCDriverClassName

protected java.lang.String getJDBCDriverClassName()
Description copied from class: BaseSQLBuilderImpl
concrete implementations of SQLBuilder must elect a default driver name
Overrides:
getJDBCDriverClassName in class BaseSQLBuilderImpl

lookupDataSource

public javax.sql.DataSource lookupDataSource(java.lang.String nsUrl,
                                             java.lang.String nsUser,
                                             java.lang.String nsPasswd,
                                             java.lang.String dataSourceName)
                                      throws JboException
Overrides:
lookupDataSource in class BaseSQLBuilderImpl

isDataSourceJTABased

public boolean isDataSourceJTABased(javax.sql.DataSource ds)
Overrides:
isDataSourceJTABased in class BaseSQLBuilderImpl

getColumnNameWithFormatForQuery

protected java.lang.String getColumnNameWithFormatForQuery(java.lang.String colName,
                                                           AttributeDef attrDef,
                                                           int sqltype)
Overrides:
getColumnNameWithFormatForQuery in class BaseSQLBuilderImpl

getSqlVariantLockTrailer

protected java.lang.String getSqlVariantLockTrailer()
Description copied from class: BaseSQLBuilderImpl
This defines the string that will be post-fixed to SQL ststements to have the rows locked - if the DB is incapable of this then is should return null. Examples are: SQL Server - "WITH (HOLDLOCK)" Oracle - "FOR UPDATE NOWAIT"
Overrides:
getSqlVariantLockTrailer in class BaseSQLBuilderImpl

Business Components