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

E17503-02

oracle.jbo.server
Class BaseSQLBuilderImpl

java.lang.Object
  extended by oracle.jbo.common.CommonCriteriaAdapter
      extended by oracle.jbo.server.BaseSQLBuilderImpl
All Implemented Interfaces:
CriteriaAdapter, SQLBuilder, ViewCriteriaAdapter
Direct Known Subclasses:
OLiteSQLBuilderImpl, PointBaseSQLBuilderImpl, SQL92SQLBuilderImpl, SQLiteSQLBuilderImpl

public class BaseSQLBuilderImpl
extends CommonCriteriaAdapter
implements SQLBuilder, ViewCriteriaAdapter


Field Summary
static java.lang.Class CLASS_INSTANCE
           
 
Fields inherited from class oracle.jbo.common.CommonCriteriaAdapter
BETWEEN, IN, IS, LIKE, LIKE_QOT, NOT, NULL, QOT, QOTSTR
 
Fields inherited from interface oracle.jbo.server.SQLBuilder
BINDING_STYLE_JDBC, BINDING_STYLE_ORACLE, BINDING_STYLE_ORACLE_NAME, BINDING_STYLE_UNKNOWN, DML_DELETE, DML_INSERT, DML_UPDATE
 
Constructor Summary
BaseSQLBuilderImpl()
           
 
Method Summary
static void baseBuildSelectList(java.lang.StringBuffer buffer, AttributeDefImpl[] attrs, java.lang.String sourceName, boolean forViewObject)
          Creates a list of columns to be selected skipping the persistent and derived attributes.
 int bindDeleteStatement(EntityImpl entityContext, PreparedStatement stmt)
          Binds the values in the entity attribute storage with the DELETE statement.
 int bindInsertStatement(EntityImpl entityContext, PreparedStatement stmt, AttributeDefImpl[] cols, AttributeDefImpl[] retrCols, AttributeDefImpl[] retrKeyCols, java.util.Hashtable retrList, boolean batchMode)
          Binds the entity attribute storage with the parameters in the INSERT statement.
 int bindInsertStatement(EntityImpl entityContext, PreparedStatement stmt, AttributeDefImpl[] cols, AttributeDefImpl[] retrCols, AttributeDefImpl[] retrKeyCols, Map retrList, boolean batchMode)
          Binds the entity attribute storage with the parameters in the INSERT statement.
 int bindOptUpdateWhereClause(EntityImpl entityContext, PreparedStatement stmt, int bindIndex)
          This method binds the unfetched attributes or a changed attribute of an entity definition.
 void bindParametersForStmt(int bindingStyle, java.lang.Object[] params, PreparedStatement stmt)
          Bind parameter values for a SQL execution.
protected  int bindParamValue(int bindingStyle, java.lang.Object value, DBTransactionImpl trans, PreparedStatement stmt, AttributeDefImpl attrDef, int bindIndex, boolean skipNull)
           
 int bindUpdateStatement(EntityImpl entityContext, PreparedStatement stmt, AttributeDefImpl[] cols, AttributeDefImpl[] retrCols, AttributeDefImpl[] retrKeyCols, java.util.Hashtable retrList, boolean batchMode)
          Binds the entity attribute storage with the parameters in the UPDATE statement.
 int bindUpdateStatement(EntityImpl entityContext, PreparedStatement stmt, AttributeDefImpl[] cols, AttributeDefImpl[] retrCols, AttributeDefImpl[] retrKeyCols, Map retrList, boolean batchMode)
          Binds the entity attribute storage with the parameters in the UPDATE statement.
protected  int bindWhereAttrValue(EntityImpl entityContext, DBTransactionImpl trans, PreparedStatement stmt, AttributeDefImpl attrDef, int bindIndex, boolean skipNull)
          Binds an attribute value to the Statement's WHERE clause parameter index dealing with Null values appropriately.
 int bindWhereClause(EntityImpl entityContext, PreparedStatement stmt, AttributeDefImpl[] keyCols, java.lang.Object rowid, int bindIndex)
          Bind the Primary key values for the designated Statement.
 int bindWhereClause(EntityImpl entityContext, PreparedStatement stmt, java.lang.Object rowid, int bindIndex)
           
 void buildDefaultViewObjectFromClause(java.lang.StringBuffer fromClause, Vector eRefs, BaseViewCriteriaManagerImpl vcManager)
          This method is used to generate the "from" clause if the following conditions are met: The View Object definition does not have an expert mode query The View Object definition is set to generate "from" clause during runtime, either in metadata or by calling ViewDefImpl.setFromClauseFlags(ViewDefImpl.CLAUSE_GENERATE_RT)
 void buildDefaultViewObjectWhereClause(java.lang.StringBuffer whereClause, Vector eRefs)
          This method is used to generate the "where" clause if the following conditions are met: The View Object definition does not specify "where" clause The View Object definition is set to generate "where" clause during runtime, either in metadata or by calling ViewDefImpl.setWhereClauseFlags(ViewDefImpl.CLAUSE_GENERATE_RT)
 java.lang.StringBuffer buildDeleteStatement(EntityImpl entityContext)
          Build a DELETE SQL for the Entity Object.
 java.lang.StringBuffer buildInsertStatement(EntityImpl entityContext, AttributeDefImpl[] cols, AttributeDefImpl[] retrCols, AttributeDefImpl[] retrKeyCols, boolean batchMode)
          Build a INSERT SQL for the Entity Object skipping non-persistent values.
 void buildOptUpdateWhereClause(EntityImpl entityContext, java.lang.StringBuffer buffer, AttributeDefImpl[] cols)
          This method binds the unfetched attributes in the list or the change indicator column of an entity definition.
 void buildSelectList(java.lang.StringBuffer buffer, AttributeDefImpl[] attrs, java.lang.String sourceAlias, boolean forViewObject)
          Build a list of columns that could be used in a SELECT statement.
 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  void buildSelectString(java.lang.StringBuffer buffer, java.lang.String sourceName, AttributeDefImpl[] attrs, boolean withIntoClause)
          Construct a SQL SELECT statement for the Entity into the designated Buffer.
 java.lang.StringBuffer buildUpdateStatement(EntityImpl entityContext, AttributeDefImpl[] cols, AttributeDefImpl[] retrCols, AttributeDefImpl[] retrKeyCols, boolean batchMode)
          Build a UPDATE SQL for the Entity Object skipping non-persistent values.
 void buildWhereClause(EntityImpl entityContext, java.lang.StringBuffer buffer, AttributeDefImpl[] keyCols, java.lang.Object rowId)
          Creates a WHERE clause containing the Primary Key columns passed to the method.
protected  boolean capabilityCanReuseLockStatements()
          Check if the a cached prepared statement to lock a row can be reused for this database flavor.
 boolean compareFetchedValue(EntityImpl entity, AttributeDefImpl ad, java.lang.Object cacheValue, java.lang.Object fetchedValue)
          Compare the cacheValue with fetchedValue and if they are equal return true This API is used when comparing cached entity with a faulted in entity.
 java.lang.Object convertValueToStorageType(java.lang.Object value)
          This method is used to convert the Java type to a JDBC type so that it could be used to bind as a parameter for SQL execution.
protected  LongRunningStatementHandle createHandleForCancellableStatements(DBTransactionImpl trans, Statement stmt)
          Creates a handle that could be used later to terminate a long running statment.
 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.
 void doEntitySelectForAltKey(EntityImpl entityContext, int keyIndex, boolean lock)
           
 java.lang.Object[] doLoadBulkFromResultSet(AttributeDefImpl[] attrDefs, int attrIndex, 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, 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, PreparedStatement ps, int index, Transaction trans)
          Loads an object from a result set.
 void doPreparedStatementDefineColumnType(PreparedStatement ps, int colnum, int sqltype)
          Performs the equivalent of defineColumnType() on a prepared statement.
 void doPreparedStatementDefines(PreparedStatement ps, AttributeDefImpl[] attrs)
          Defines the column types of the attributes based on the meta-data.
 void doRefreshSQL(EntityImpl entityContext, int operation, AttributeDefImpl[] columns, AttributeDefImpl[] retrKeyCols)
          Refreshes the entity after an update on the database.
 void doStatementSetBindingStyle(Statement ps, int bindingStyle)
          Sets the binding style for the statement.
 void doStatementSetBindingStyleDefault(Statement ps)
          Sets the binding style to the default value of the database type.
 void doStatementSetRowPrefetch(Statement ps, int prefetchSize)
          Performs the equivalent of setRowPrefetch() on a statement.
protected  java.lang.Object formatAttributeValue(ViewCriteria vc, AttributeDef curDef, java.lang.String valString)
           
 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)
          Get the ROWID attribute.
static int getBindingStyleValue(java.lang.String bindingStyleStr)
           
 java.lang.String getClauseForDateLiteral(java.util.Date date)
          Creates a database platform specific clause for converting a date string literal to date datatype.
 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).
protected  boolean getLockTrailerIsAtEnd()
          For some databases like SQLServer that row lock clause is placed before the WHERE clause while for some other databases like Oracle it is at the end of SQL Statement.
 java.lang.String getQueryHitCountSQL(RowSet rs)
          Returns a SQL statement to estimate the number of rows effected by the query using the rowset values.
protected  java.lang.Object getROWID(EntityImpl entityContext)
          Get the ROWID attribute.
protected  java.lang.String getSqlVariantLockTrailer()
          This defines the string that will be post-fixed to SQL statements to have the rows locked - if the DB is incapable of this then it should return null.
protected  boolean getSupportsAliasInUpdateStatements()
          Assume that aliases are permitted, unless a builder denies it
 ViewCriteriaAdapter getViewCriteriaAdapter()
          Returns a ViewCriteriaAdapter for the SQLBuilder object.
 java.lang.String getViewCriteriaClause(ViewObject vo, ViewCriteria vc)
           
protected  java.lang.String getWarningText(java.lang.String message)
          For use withinn DebugDiagnostic messages.
 void populateCompOpers()
           
 void processException(java.lang.Class callingClass, java.lang.String callingMethod, java.lang.String errorCode, java.lang.Exception sqlEx, java.lang.Object[] params)
          Handle SQL exceptions by wrapping into SQLStmtException or JboException.
 java.lang.Object registerDatabaseChangeListener(QueryCollection listener, Connection conn, Statement stmt)
          Register a Query Collection to listen to database data change events.
 void releaseSavepoint(Connection conn, java.lang.String id)
          Release SAVEPOINT if possible.
 void rollbackToSavepoint(Connection conn, java.lang.String id)
          Rollback to SAVEPOINT if possible.
 void setSavepoint(Connection conn, java.lang.String id)
          Issue a SAVEPOINT if possible.
protected  java.lang.String setupBindVarExtendedData(ViewCriteria criteria, java.lang.String criteriaClause)
          Subclasses should overwrite this method if it needs to set up extended data for bind variables for JDBC positional binding style, and to replace the name bind variables in the where clause if necessary.
 boolean shouldPutJoinConstraintInFromClause()
          Checks if the FROM clause allows view criteria.
protected  boolean shouldSkipDML(EntityImpl entityContext, int operation, TransactionEvent e)
          Checks if the entity needs to be posted to the database or not.
 boolean supportsRowNumQuery()
          Checks if the database supports "rownum" identifier.
 void unregisterDatabaseChangeListener(java.lang.Object handle)
          UnRegister a previous registration to listen to database data change events.
 
Methods inherited from class oracle.jbo.common.CommonCriteriaAdapter
cleanUpTemporaryBindVars, convertCriteriaItemToWhereFragment, convertOpandRHSToWhereFragment, convertValueToWhereFragment, correctOprandLiteral, createTempBindVar, createTemporaryBindVar, getCriteriaClause, getCriteriaClause, getFormattedLHSCompareFragment, getFormattedLHSCompareFragment, getFormattedRHSCompareFragment, getOptionalItemClause, getWhereFragmentFromVO, isCharType, isDateType, isLHSFragmentOptional, isNumericType, parseOperatorAndValueFromItemValue, shouldUseTempBindVariableForValue
 
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

BaseSQLBuilderImpl

public BaseSQLBuilderImpl()
Method Detail

buildDeleteStatement

public java.lang.StringBuffer buildDeleteStatement(EntityImpl entityContext)
Description copied from interface: SQLBuilder
Build a DELETE SQL for the Entity Object. The row is deleted from the table using the values of the Primary keys defined in the Entity.

Note: this method is subject to change.

Specified by:
buildDeleteStatement in interface SQLBuilder
Parameters:
entityContext - the entity object.
Returns:
a StringBuffer object containing the UPDATE statement.

buildInsertStatement

public java.lang.StringBuffer buildInsertStatement(EntityImpl entityContext,
                                                   AttributeDefImpl[] cols,
                                                   AttributeDefImpl[] retrCols,
                                                   AttributeDefImpl[] retrKeyCols,
                                                   boolean batchMode)
Description copied from interface: SQLBuilder
Build a INSERT SQL for the Entity Object skipping non-persistent values. If there are attributes in the Entity Object that need to be fetched after the INSERT succeeds, a CallableStatement is created to fetch those values.

Note: this method is subject to change.

Specified by:
buildInsertStatement in interface SQLBuilder
Parameters:
entityContext - the entity object.
cols - the columns to be included in the INSERT statement.
retrCols - the Columns whose values need to be fetched after the INSERT succeeds.
retrKeyCols - the Columns that are used as Keys to fetch post-insert values.
batchMode - a flag to indicate if the INSERT statement needs to be optimized for batch mode.
Returns:
a StringBuffer object containing the INSERT statement.

buildUpdateStatement

public java.lang.StringBuffer buildUpdateStatement(EntityImpl entityContext,
                                                   AttributeDefImpl[] cols,
                                                   AttributeDefImpl[] retrCols,
                                                   AttributeDefImpl[] retrKeyCols,
                                                   boolean batchMode)
Description copied from interface: SQLBuilder
Build a UPDATE SQL for the Entity Object skipping non-persistent values. If there are attributes in the Entity Object that need to be fetched after the UPDATE succeeds, a CallableStatement is created to fetch those values.

Note: this method is subject to change.

Specified by:
buildUpdateStatement in interface SQLBuilder
Parameters:
entityContext - the entity object.
cols - the columns to be included in the UPDATE statement.
retrCols - the Columns whose values need to be fetched after the UPDATE succeeds.
retrKeyCols - the Columns that are used as Keys to fetch post-update values.
batchMode - a flag to indicate if the UPDATE statement needs to be optimized for batch mode.
Returns:
a StringBuffer object containing the UPDATE statement.

bindWhereAttrValue

protected int bindWhereAttrValue(EntityImpl entityContext,
                                 DBTransactionImpl trans,
                                 PreparedStatement stmt,
                                 AttributeDefImpl attrDef,
                                 int bindIndex,
                                 boolean skipNull)
                          throws SQLException
Binds an attribute value to the Statement's WHERE clause parameter index dealing with Null values appropriately. The attribute value is not yet poupulated in the Entity definition it is fetched and then bound.

Parameters:
entityContext - the entity object.
trans - the transaction object.
stmt - the Statement object carrying out the SQL.
attrDef - the defintion of the attribute to which the value belongs.
bindIndex - the parameter index in the PreparedStatement.
skipNull - indicates if the null values need to be bound or skipped.
Returns:
a new bind index value so that this method can be invoked in a loop.
Throws:
SQLException

shouldSkipDML

protected boolean shouldSkipDML(EntityImpl entityContext,
                                int operation,
                                TransactionEvent e)
Checks if the entity needs to be posted to the database or not.

Parameters:
entityContext - the entity object.
operation - the type of operation. For example INSERT, UPDATE.
e - the transaction event triggered.
Returns:
true if the entity is already posted, false otherwise.

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
Parameters:
entityContext - the Entity Object.
operation - one of DML_INSERT, DML_UPDATE, or DML_DELETE.
e - the transaction.

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".

Specified by:
getDbType in interface SQLBuilder
Returns:
a String containing the Database type.

buildWhereClause

public void buildWhereClause(EntityImpl entityContext,
                             java.lang.StringBuffer buffer,
                             AttributeDefImpl[] keyCols,
                             java.lang.Object rowId)
Description copied from interface: SQLBuilder
Creates a WHERE clause containing the Primary Key columns passed to the method.

Note: this method is subject to change.

Specified by:
buildWhereClause in interface SQLBuilder
Parameters:
entityContext - the entity object.
buffer - the StringBuffer object to which the WHERE clause is appended.
keyCols - the key attributes.
rowId - a rowid object if present.

bindUpdateStatement

public int bindUpdateStatement(EntityImpl entityContext,
                               PreparedStatement stmt,
                               AttributeDefImpl[] cols,
                               AttributeDefImpl[] retrCols,
                               AttributeDefImpl[] retrKeyCols,
                               java.util.Hashtable retrList,
                               boolean batchMode)
                        throws SQLException
Description copied from interface: SQLBuilder
Binds the entity attribute storage with the parameters in the UPDATE statement.

Note: this method is subject to change.

Specified by:
bindUpdateStatement in interface SQLBuilder
Parameters:
entityContext - the entity object.
stmt - the statement handle executing the UPDATE statement.
cols - the columns involved in the UPDATE statement.
retrCols - the columns whose values need to be fetched after a successful insert.
retrKeyCols - the columns that act as a key to fetch the newly inserted values.
retrList - a map containing the references to store the fetched values.
batchMode - flag to indicate binding for batchMode.
Returns:
index of last bind variable set in this statement.
Throws:
SQLException

bindWhereClause

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

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

Note: this method is subject to change.

Specified by:
bindWhereClause in interface SQLBuilder
Parameters:
entityContext - the Entity row.
stmt - the statement to bind the columns to.
rowid - the ROWID for the row if known.
bindIndex - the baseline idx for performing the bind operations.
Returns:
index of last bind variable set in this statement.
Throws:
SQLException

bindInsertStatement

public int bindInsertStatement(EntityImpl entityContext,
                               PreparedStatement stmt,
                               AttributeDefImpl[] cols,
                               AttributeDefImpl[] retrCols,
                               AttributeDefImpl[] retrKeyCols,
                               java.util.Hashtable retrList,
                               boolean batchMode)
                        throws SQLException
Description copied from interface: SQLBuilder
Binds the entity attribute storage with the parameters in the INSERT statement.

Note: this method is subject to change.

Specified by:
bindInsertStatement in interface SQLBuilder
Parameters:
entityContext - the entity object.
stmt - the statement handle executing the INSERT statement.
cols - the columns involved in the INSERT statement.
retrCols - the columns whose values need to be fetched after a successful insert.
retrKeyCols - the columns that act as a key to fetch the newly inserted values.
retrList - a map containing the references to store the fetched values.
batchMode - flag to indicate binding for batchMode.
Returns:
index of last bind variable set in this statement.
Throws:
SQLException

bindDeleteStatement

public int bindDeleteStatement(EntityImpl entityContext,
                               PreparedStatement stmt)
                        throws SQLException
Description copied from interface: SQLBuilder
Binds the values in the entity attribute storage with the DELETE statement.

Note: this method is subject to change.

Specified by:
bindDeleteStatement in interface SQLBuilder
Parameters:
entityContext - the entity object.
stmt - the statement handle executing the DELETE statement.
Throws:
SQLException

bindParametersForStmt

public void bindParametersForStmt(int bindingStyle,
                                  java.lang.Object[] params,
                                  PreparedStatement stmt)
                           throws SQLException
Description copied from interface: SQLBuilder
Bind parameter values for a SQL execution.

Note: this method is subject to change.

Specified by:
bindParametersForStmt in interface SQLBuilder
Parameters:
bindingStyle - specifies if Oracle, Oracle named parameter or JDBC binding style is used.
params - the list of parameters.
stmt - the statement to be executed.
Throws:
SQLException

bindParamValue

protected int bindParamValue(int bindingStyle,
                             java.lang.Object value,
                             DBTransactionImpl trans,
                             PreparedStatement stmt,
                             AttributeDefImpl attrDef,
                             int bindIndex,
                             boolean skipNull)
                      throws SQLException
Throws:
SQLException

baseBuildSelectList

public static void baseBuildSelectList(java.lang.StringBuffer buffer,
                                       AttributeDefImpl[] attrs,
                                       java.lang.String sourceName,
                                       boolean forViewObject)
Creates a list of columns to be selected skipping the persistent and derived attributes.

Parameters:
buffer - the storage for the WHERE clause.
attrs - the attributes to be considered for the select list.
sourceName - the name of the table - unused.

buildSelectList

public void buildSelectList(java.lang.StringBuffer buffer,
                            AttributeDefImpl[] attrs,
                            java.lang.String sourceAlias,
                            boolean forViewObject)
Description copied from interface: SQLBuilder
Build a list of columns that could be used in a SELECT statement.

Note: this method is subject to change.

Specified by:
buildSelectList in interface SQLBuilder
Parameters:
buffer - the StringBuffer object to which the SELECT list is appended.
attrs - the list of attribute definitions to be considered for the SELECT list.
sourceAlias - the database object name that contains the attributes.

buildDefaultViewObjectFromClause

public void buildDefaultViewObjectFromClause(java.lang.StringBuffer fromClause,
                                             Vector eRefs,
                                             BaseViewCriteriaManagerImpl vcManager)
Description copied from interface: SQLBuilder
This method is used to generate the "from" clause if the following conditions are met:
  • The View Object definition does not have an expert mode query
  • The View Object definition is set to generate "from" clause during runtime, either in metadata or by calling ViewDefImpl.setFromClauseFlags(ViewDefImpl.CLAUSE_GENERATE_RT)
  • Specified by:
    buildDefaultViewObjectFromClause in interface SQLBuilder
    Parameters:
    fromClause - A StringBuffer object that would be appended with the generated "from" clause.
    eRefs - The EntityReference objects that should be considered for generation of the "from" clause.
    vcManager - In ANSI generation, view criteria associated with the EntityAssociationReference are part of the FROM clause, and vcManager is used to build the where clause fragment. if NULL, view criteria won't be built

    shouldPutJoinConstraintInFromClause

    public boolean shouldPutJoinConstraintInFromClause()
    Description copied from interface: SQLBuilder
    Checks if the FROM clause allows view criteria. In ANSI SQL generation, join constraint view criteria are part of the ON clause.

    Specified by:
    shouldPutJoinConstraintInFromClause in interface SQLBuilder
    Returns:
    false for Oracle database and true otherwise.

    getViewCriteriaAdapter

    public ViewCriteriaAdapter getViewCriteriaAdapter()
    Description copied from interface: SQLBuilder
    Returns a ViewCriteriaAdapter for the SQLBuilder object. ViewCriteriaAdapter is used in creating WHERE clause based on a set of criteria for a ViewObject.

    Note: this method is subject to change.

    Specified by:
    getViewCriteriaAdapter in interface SQLBuilder
    Returns:
    a ViewCriteriaAdapter instance.

    getViewCriteriaClause

    public java.lang.String getViewCriteriaClause(ViewObject vo,
                                                  ViewCriteria vc)
    Specified by:
    getViewCriteriaClause in interface ViewCriteriaAdapter

    formatAttributeValue

    protected java.lang.Object formatAttributeValue(ViewCriteria vc,
                                                    AttributeDef curDef,
                                                    java.lang.String valString)
    Specified by:
    formatAttributeValue in class CommonCriteriaAdapter

    buildDefaultViewObjectWhereClause

    public void buildDefaultViewObjectWhereClause(java.lang.StringBuffer whereClause,
                                                  Vector eRefs)
    Description copied from interface: SQLBuilder
    This method is used to generate the "where" clause if the following conditions are met:
  • The View Object definition does not specify "where" clause
  • The View Object definition is set to generate "where" clause during runtime, either in metadata or by calling ViewDefImpl.setWhereClauseFlags(ViewDefImpl.CLAUSE_GENERATE_RT)
  • Specified by:
    buildDefaultViewObjectWhereClause in interface SQLBuilder
    Parameters:
    whereClause - A StringBuffer object that would be appended with the generated "where" clause.
    eRefs - The EntityReference objects that should be considered for generation of the "where" clause.

    convertValueToStorageType

    public java.lang.Object convertValueToStorageType(java.lang.Object value)
    Description copied from interface: SQLBuilder
    This method is used to convert the Java type to a JDBC type so that it could be used to bind as a parameter for SQL execution.

    Note: this method is subject to change.

    Specified by:
    convertValueToStorageType in interface SQLBuilder
    Parameters:
    value - the object that needs to be converted.
    Returns:
    the JDBC type.

    doStatementSetBindingStyle

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

    Specified by:
    doStatementSetBindingStyle in interface SQLBuilder
    Parameters:
    ps - the Statement object.
    bindingStyle - valid values are BINDING_STYLE_JDBC, BINDING_STYLE_ORACLE, BINDING_STYLE_ORACLE_NAME.

    doStatementSetRowPrefetch

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

    Specified by:
    doStatementSetRowPrefetch in interface SQLBuilder
    Parameters:
    ps - the Statement object.
    prefetchSize - the fetch size.
    Throws:
    SQLException

    getClauseForDateLiteral

    public java.lang.String getClauseForDateLiteral(java.util.Date date)
    Description copied from interface: SQLBuilder
    Creates a database platform specific clause for converting a date string literal to date datatype. May be used in date comparisions and other manipulations.

    Specified by:
    getClauseForDateLiteral in interface SQLBuilder
    Parameters:
    date - The date object that will be formatted and passed as a String
    Returns:
    A string representing the clause to be used while building the query statement.

    supportsRowNumQuery

    public boolean supportsRowNumQuery()
    Description copied from interface: SQLBuilder
    Checks if the database supports "rownum" identifier. Used for fetching rows in the specified range.

    Note: this method is subject to change.

    Specified by:
    supportsRowNumQuery in interface SQLBuilder
    Returns:
    true for Oracle database and false otherwise.

    getBindingStyleValue

    public static int getBindingStyleValue(java.lang.String bindingStyleStr)

    doLoadFromResultSet

    public java.lang.Object doLoadFromResultSet(java.lang.Object theTypeFactory,
                                                java.lang.Object theElemFactory,
                                                java.lang.Class theJavaType,
                                                byte attrLoad,
                                                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
    Parameters:
    theTypeFactory - a custom factory to be used for constructing new instances.
    theElemFactory - currently unused.
    theJavaType - the Java datatype of the Object to be created.
    attrLoad - specifies if the load type is ATTR_LOAD_EACH, ATTR_LOAD_BULK or ATTR_LOAD_SKIP
    rs - the resultset.
    index - the index of the object to be loaded.
    trans - the reference to the transaction object used to fetch the resultset.
    Returns:
    a reference to the object loaded.

    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. Note: this method is subject to change.

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

    capabilityCanReuseLockStatements

    protected boolean capabilityCanReuseLockStatements()
    Check if the a cached prepared statement to lock a row can be reused for this database flavor.

    Returns:
    returns a default of true. Specialized SQLBuilders override this method.

    buildSelectString

    protected void buildSelectString(java.lang.StringBuffer buffer,
                                     java.lang.String sourceName,
                                     AttributeDefImpl[] attrs,
                                     boolean withIntoClause)
    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.
    sourceName - the database object from which the Columns are selected.
    attrs - the attributes that are selected from the database object.
    withIntoClause - a boolean that indicates if an INTO Clause needs to be generated.

    doEntitySelectForAltKey

    public void doEntitySelectForAltKey(EntityImpl entityContext,
                                        int keyIndex,
                                        boolean lock)
    Specified by:
    doEntitySelectForAltKey in interface SQLBuilder

    getSqlVariantLockTrailer

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

    Returns:
    the lock clause.

    getLockTrailerIsAtEnd

    protected boolean getLockTrailerIsAtEnd()
    For some databases like SQLServer that row lock clause is placed before the WHERE clause while for some other databases like Oracle it is at the end of SQL Statement.

    Returns:
    true if the row lock clause is at the end, false otherwise.

    generateRowID

    public java.lang.Object generateRowID(EntityImpl entityContext)
    Description copied from interface: SQLBuilder
    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.

    Note: this method is subject to change.

    Specified by:
    generateRowID in interface SQLBuilder
    Parameters:
    entityContext - the entity object reference.
    Returns:
    an Object containing the ROWID or null if generate ROWID fails.

    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.

    Note: this method is subject to change.

    Specified by:
    generateRefAndOID in interface SQLBuilder
    Parameters:
    entityContext - the entity object reference.

    compareFetchedValue

    public boolean compareFetchedValue(EntityImpl entity,
                                       AttributeDefImpl ad,
                                       java.lang.Object cacheValue,
                                       java.lang.Object fetchedValue)
    Description copied from interface: SQLBuilder
    Compare the cacheValue with fetchedValue and if they are equal return true This API is used when comparing cached entity with a faulted in entity. Signature modified since 9.0.5.1 to allow for Entity context to be available during compare so that Applications could perform custom comparision logic based on either settings in the Entity or any other context available via the entity.

    Note: this method is subject to change.

    Specified by:
    compareFetchedValue in interface SQLBuilder
    Parameters:
    entity - the entity object.
    ad - the attribute definition of the value being compared.
    cacheValue - the cached value.
    fetchedValue - the new fetched value.
    Returns:
    true if the values are same, false otherwise.

    doLoadBulkFromResultSet

    public java.lang.Object[] doLoadBulkFromResultSet(AttributeDefImpl[] attrDefs,
                                                      int attrIndex,
                                                      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
    Parameters:
    attrDefs - the list of attributes to be loaded.
    attrIndex - a particular attribute from the list - Currently unused.
    rs - the ResultSet containing the objects.
    index - the index of the object in the result set to be loaded.
    trans - the reference to the transaction object used to fetch the resultset.
    Returns:
    a reference to the array of objects loaded.

    registerDatabaseChangeListener

    public java.lang.Object registerDatabaseChangeListener(QueryCollection listener,
                                                           Connection conn,
                                                           Statement stmt)
    Description copied from interface: SQLBuilder
    Register a Query Collection to listen to database data change events. Currently this is available for Oracle database only.

    Specified by:
    registerDatabaseChangeListener in interface SQLBuilder
    Parameters:
    listener - The Query Collection that holds the qualifying rows
    conn - Connection object
    stmt - The SQL Statement that needs to be monitored for the database to trigger notifications.
    Returns:
    An object that represents a registration handle that could be used to unregister.

    doPreparedStatementDefines

    public void doPreparedStatementDefines(PreparedStatement ps,
                                           AttributeDefImpl[] attrs)
    Description copied from interface: SQLBuilder
    Defines the column types of the attributes based on the meta-data.

    Note: this method is subject to change.

    Specified by:
    doPreparedStatementDefines in interface SQLBuilder
    Parameters:
    ps - the PreparedStatement object.
    attrs - the attribute definitions.

    processException

    public void processException(java.lang.Class callingClass,
                                 java.lang.String callingMethod,
                                 java.lang.String errorCode,
                                 java.lang.Exception sqlEx,
                                 java.lang.Object[] params)
    Description copied from interface: SQLBuilder
    Handle SQL exceptions by wrapping into SQLStmtException or JboException.

    Note: this method is subject to change.

    Specified by:
    processException in interface SQLBuilder
    errorCode - the SQL execution errorcode.
    sqlEx - the Exception object.
    params - the query parameters.

    unregisterDatabaseChangeListener

    public void unregisterDatabaseChangeListener(java.lang.Object handle)
    Description copied from interface: SQLBuilder
    UnRegister a previous registration to listen to database data change events.

    Specified by:
    unregisterDatabaseChangeListener in interface SQLBuilder

    populateCompOpers

    public void populateCompOpers()

    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.

    Note: this method is subject to change.

    Specified by:
    generatePKBasedRef in interface SQLBuilder
    Parameters:
    entityContext - the entity object reference.

    bindWhereClause

    public int bindWhereClause(EntityImpl entityContext,
                               PreparedStatement stmt,
                               java.lang.Object rowid,
                               int bindIndex)
                        throws SQLException
    Throws:
    SQLException

    createHandleForCancellableStatements

    protected LongRunningStatementHandle createHandleForCancellableStatements(DBTransactionImpl trans,
                                                                              Statement stmt)
    Creates a handle that could be used later to terminate a long running statment. The long running statements for the entity objects are tracked on a transaction object. When Transaction.cancelDMLStatements() is invoked, the long running statements running to execute DMLs for all the entity objects under this transactions are terminated.

    Parameters:
    trans - the transaction object.
    stmt - the statement handle.
    Returns:
    a long running statement handle.

    rollbackToSavepoint

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

    Specified by:
    rollbackToSavepoint in interface SQLBuilder
    Parameters:
    conn - the Connection used to rollback the savepoint.
    id - the id for a savepoint
    Throws:
    SQLException

    setSavepoint

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

    Specified by:
    setSavepoint in interface SQLBuilder
    Parameters:
    conn - the Connection used to create a savepoint.
    id - the id for a savepoint.
    Throws:
    SQLException

    releaseSavepoint

    public void releaseSavepoint(Connection conn,
                                 java.lang.String id)
                          throws SQLException
    Description copied from interface: SQLBuilder
    Release SAVEPOINT if possible.

    Specified by:
    releaseSavepoint in interface SQLBuilder
    Parameters:
    conn - the Connection used to release the savepoint.
    id - the id for a savepoint
    Throws:
    SQLException

    doRefreshSQL

    public void doRefreshSQL(EntityImpl entityContext,
                             int operation,
                             AttributeDefImpl[] columns,
                             AttributeDefImpl[] retrKeyCols)
    Description copied from interface: SQLBuilder
    Refreshes the entity after an update on the database. The refresh depends entirely on, the attributes which were modified. If no UNIQUE/PRIMARY KEY attribute was set in the application, or they are modified in a database trigger then the refresh may not be able to find the required row. In this situation RowNotFoundException will be thrown. If there is good reason behind not setting any of the KEY attributes, then, in a custom SQLBuilder, this method should be overriden.

    Note: this method is subject to change.

    Specified by:
    doRefreshSQL in interface SQLBuilder
    Parameters:
    entityContext - the Entity row.
    operation - SQL Operation
    columns - Columns to be selected.
    retrKeyCols - Key columns to appear be to used to refresh, which appear in WHERE clause.

    buildSelectString

    public void buildSelectString(DBTransactionImpl trans,
                                  java.lang.StringBuffer buffer,
                                  java.lang.String sourceName,
                                  java.lang.String sourceAlias,
                                  AttributeDefImpl[] attrs,
                                  boolean withIntoClause,
                                  int bindingStyle)
    Description copied from interface: SQLBuilder
    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.

    Note: this method is subject to change.

    Specified by:
    buildSelectString in interface SQLBuilder
    Parameters:
    trans - a reference to the transaction object.
    buffer - the StringBuffer object to which the SELECT statement is appended.
    sourceName - the database object from which the Columns are selected.
    sourceAlias - the database object alias.
    attrs - the attributes that are selected from the database object.
    withIntoClause - a boolean that indicates if an INTO Clause needs to be generated.
    bindingStyle - specifies if Oracle, Oracle named parameter or JDBC binding style is used in generating the parameter markers for the INTO clause.

    bindUpdateStatement

    public int bindUpdateStatement(EntityImpl entityContext,
                                   PreparedStatement stmt,
                                   AttributeDefImpl[] cols,
                                   AttributeDefImpl[] retrCols,
                                   AttributeDefImpl[] retrKeyCols,
                                   Map retrList,
                                   boolean batchMode)
                            throws SQLException
    Description copied from interface: SQLBuilder
    Binds the entity attribute storage with the parameters in the UPDATE statement.

    Note: this method is subject to change.

    Specified by:
    bindUpdateStatement in interface SQLBuilder
    Parameters:
    entityContext - the entity object.
    stmt - the statement handle executing the UPDATE statement.
    cols - the columns involved in the UPDATE statement.
    retrCols - the columns whose values need to be fetched after a successful insert.
    retrKeyCols - the columns that act as a key to fetch the newly inserted values.
    retrList - a map containing the references to store the fetched values.
    batchMode - flag to indicate binding for batchMode.
    Returns:
    index of last bind variable set in this statement.
    Throws:
    SQLException

    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.

    Parameters:
    entityContext - the entity object.
    Returns:
    the value of the ROWID attribute or null if not present or applicable to this entity.

    bindInsertStatement

    public int bindInsertStatement(EntityImpl entityContext,
                                   PreparedStatement stmt,
                                   AttributeDefImpl[] cols,
                                   AttributeDefImpl[] retrCols,
                                   AttributeDefImpl[] retrKeyCols,
                                   Map retrList,
                                   boolean batchMode)
                            throws SQLException
    Description copied from interface: SQLBuilder
    Binds the entity attribute storage with the parameters in the INSERT statement.

    Note: this method is subject to change.

    Specified by:
    bindInsertStatement in interface SQLBuilder
    Parameters:
    entityContext - the entity object.
    stmt - the statement handle executing the INSERT statement.
    cols - the columns involved in the INSERT statement.
    retrCols - the columns whose values need to be fetched after a successful insert.
    retrKeyCols - the columns that act as a key to fetch the newly inserted values.
    retrList - a map containing the references to store the fetched values.
    batchMode - flag to indicate binding for batchMode.
    Returns:
    index of last bind variable set in this statement.
    Throws:
    SQLException

    doLoadFromStatement

    public java.lang.Object doLoadFromStatement(java.lang.Object theTypeFactory,
                                                java.lang.Object theElemFactory,
                                                java.lang.Class theJavaType,
                                                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
    Parameters:
    theTypeFactory - a custom factory to be used for constructing new instances.
    theElemFactory - currently unused.
    theJavaType - the Java datatype of the Object to be created.
    ps - the statement reference used to retrieve the Object.
    index - the index of the object in the output list.
    trans - the reference to the transaction object used to fetch the resultset.
    Returns:
    a reference to the object loaded.

    getSupportsAliasInUpdateStatements

    protected boolean getSupportsAliasInUpdateStatements()
    Assume that aliases are permitted, unless a builder denies it

    Returns:
    true if aliases are supported, false otherwise
    Since:
    10.1.2 29Jul04

    buildOptUpdateWhereClause

    public void buildOptUpdateWhereClause(EntityImpl entityContext,
                                          java.lang.StringBuffer buffer,
                                          AttributeDefImpl[] cols)
    This method binds the unfetched attributes in the list or the change indicator column of an entity definition.

    Parameters:
    entityContext - the entity definition.
    buffer - the storage for the WHERE clause.
    cols - the attributes to be considered for fetching.

    doStatementSetBindingStyleDefault

    public void doStatementSetBindingStyleDefault(Statement ps)
    Description copied from interface: SQLBuilder
    Sets the binding style to the default value of the database type. For Oracle database it is set to BINDING_STYLE_ORACLE and for non-oracle databases it is set to BINDING_STYLE_JDBC.

    Note: this method is subject to change.

    Specified by:
    doStatementSetBindingStyleDefault in interface SQLBuilder
    Parameters:
    ps - the Statement object.

    getDefaultBindingStyle

    public int getDefaultBindingStyle()
    Unless overridden, the binding style is set to JDBC (Oracle versions change this).

    Returns:
    an int value of SQLBuilder.BINDING_STYLE_JDBC.

    getQueryHitCountSQL

    public java.lang.String getQueryHitCountSQL(RowSet rs)
    Description copied from interface: SQLBuilder
    Returns a SQL statement to estimate the number of rows effected by the query using the rowset values.

    Note: this method is subject to change.

    Specified by:
    getQueryHitCountSQL in interface SQLBuilder
    Parameters:
    rs - the RowSet object.
    Returns:
    the SQL statement as a String object.

    doPreparedStatementDefineColumnType

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

    Note: this method is subject to change.

    Specified by:
    doPreparedStatementDefineColumnType in interface SQLBuilder
    Parameters:
    ps - the PreparedStatement object.
    colnum - the column number.
    sqltype - the type of the column.
    Throws:
    SQLException

    getWarningText

    protected java.lang.String getWarningText(java.lang.String message)
    For use withinn DebugDiagnostic messages.

    Parameters:
    message - the warning message.
    Returns:
    a preamble with the name of the specific implementation in force.

    setupBindVarExtendedData

    protected java.lang.String setupBindVarExtendedData(ViewCriteria criteria,
                                                        java.lang.String criteriaClause)
    Description copied from class: CommonCriteriaAdapter
    Subclasses should overwrite this method if it needs to set up extended data for bind variables for JDBC positional binding style, and to replace the name bind variables in the where clause if necessary.

    Overrides:
    setupBindVarExtendedData in class CommonCriteriaAdapter
    Parameters:
    criteria - The view criteria that we are building the where clause for
    criteriaClause - The where clause that has been generated
    Returns:
    The where clause to be used by the statement

    bindOptUpdateWhereClause

    public int bindOptUpdateWhereClause(EntityImpl entityContext,
                                        PreparedStatement stmt,
                                        int bindIndex)
                                 throws SQLException
    This method binds the unfetched attributes or a changed attribute of an entity definition.

    Parameters:
    entityContext - the entity definition.
    stmt - the Statement object.
    bindIndex - the current bind index.
    Returns:
    index of last bind variable set in this statement.
    Throws:
    SQLException

    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.