WebObjects 5.2

com.webobjects.jdbcadaptor
Class JDBCExpression

java.lang.Object
  |
  +--com.webobjects.eoaccess.EOSQLExpression
        |
        +--com.webobjects.jdbcadaptor.JDBCExpression
Direct Known Subclasses:
MicrosoftPlugIn.MicrosoftExpression, MySQLPlugIn.MySQLExpression, OpenBasePlugIn.OpenBaseExpression, OraclePlugIn.OracleExpression, SybasePlugIn.SybaseExpression

public class JDBCExpression
extends EOSQLExpression


Inner classes inherited from class com.webobjects.eoaccess.EOSQLExpression
EOSQLExpression.SQLValue
 
Fields inherited from class com.webobjects.eoaccess.EOSQLExpression
BindVariableAttributeKey, BindVariableColumnKey, BindVariableNameKey, BindVariablePlaceHolderKey, BindVariableValueKey
 
Constructor Summary
JDBCExpression(EOEntity entity)
           
 
Method Summary
 void addSelectListAttribute(EOAttribute attribute)
          Adds a SQL string for attribute to a comma-separated list of attribute names for use in a SELECT statement.
 String allowsNullClauseForConstraint(boolean allowsNull)
          Returns according to flag an adaptor specific string for use in a CREATE TABLE statement.
protected  void appendItemToListString(String sqlString)
           
protected  void appendItemToOrderByString(String sqlString)
           
protected  void appendItemToValueListString(String sqlString)
           
 NSMutableDictionary bindVariableDictionaryForAttribute(EOAttribute att, Object value)
          Implemented by subclasses to create and return the bind variable dictionary for attribute and value.
 String columnTypeStringForAttribute(EOAttribute attribute)
          Returns an adaptor specific type string for attribute that's suitable for use in a CREATE TABLE statement.
 String externalNameQuoteCharacter()
          Returns a String with the character used to quote SQL identifiers that use unusual characters which would not otherwise be legal.
 String formatValueForAttribute(Object value, EOAttribute attribute)
          This method should be overridden by subclasses to return a string representation of value suitable for use in an SQL statement, depending on attribute's externalType.
protected  NSDictionary jdbcInfo()
           
 String lockClause()
          Overridden by subclasses to return the SQL string used in a SELECT statement to lock selected rows.
 boolean mustUseBindVariableForAttribute(EOAttribute att)
          Returns true if the receiver must use bind variables for attribute, false otherwise.
 void prepareSelectExpressionWithAttributes(NSArray attributes, boolean lock, EOFetchSpecification fetchSpec)
          Generates a SELECT statement.
protected  void setJDBCInfo(NSDictionary jdbcInfo)
           
 boolean shouldUseBindVariableForAttribute(EOAttribute att)
          Returns true if the receiver can provide a bind variable dictionary for attribute, false otherwise.
 boolean useBindVariables()
          Queries if instances use bind variables.
 
Methods inherited from class com.webobjects.eoaccess.EOSQLExpression
addBindVariableDictionary, addCreateClauseForAttribute, addInsertListAttribute, addJoinClause, addOrderByAttributeOrdering, addUpdateListAttribute, aliasesByRelationshipPath, appendItemToListString, assembleDeleteStatementWithQualifier, assembleInsertStatementWithRow, assembleJoinClause, assembleSelectStatementWithAttributes, assembleUpdateStatementWithRow, bindVariableDictionaries, entity, formatSQLString, formatStringValue, joinClauseString, joinExpression, listString, orderByString, prepareConstraintStatementForRelationship, prepareDeleteExpressionForQualifier, prepareInsertExpressionWithRow, prepareUpdateExpressionWithRow, setStatement, setUseAliases, setUseBindVariables, setUseQuotedExternalNames, sqlEscapeChar, sqlPatternFromShellPattern, sqlPatternFromShellPatternWithEscapeCharacter, sqlStringForAttribute, sqlStringForAttributeNamed, sqlStringForAttributePath, sqlStringForCaseInsensitiveLike, sqlStringForConjoinedQualifiers, sqlStringForData, sqlStringForDisjoinedQualifiers, sqlStringForKeyComparisonQualifier, sqlStringForKeyValueQualifier, sqlStringForNegatedQualifier, sqlStringForNumber, sqlStringForQualifier, sqlStringForSchemaObjectName, sqlStringForSelector, sqlStringForString, sqlStringForValue, statement, tableListWithRootEntity, toString, useAliases, useQuotedExternalNames, valueList, whereClauseString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JDBCExpression

public JDBCExpression(EOEntity entity)
Method Detail

addSelectListAttribute

public void addSelectListAttribute(EOAttribute attribute)
Description copied from class: EOSQLExpression
Adds a SQL string for attribute to a comma-separated list of attribute names for use in a SELECT statement. The SQL string for attribute is formatted with its "read" format. This method invokes appendItemToListString to add the attribute name.
Overrides:
addSelectListAttribute in class EOSQLExpression
Following copied from class: com.webobjects.eoaccess.EOSQLExpression
Parameters:
attribute - the EOAttribute whose name will be added to listString
See Also:
EOSQLExpression.appendItemToListString(String aString, StringBuffer aStringBuffer), EOSQLExpression.listString(), EOSQLExpression.sqlStringForAttribute(EOAttribute anEOAttribute), EOSQLExpression.formatSQLString(String sqlString, String format), EOAttribute.readFormat()

allowsNullClauseForConstraint

public String allowsNullClauseForConstraint(boolean allowsNull)
Description copied from class: EOSQLExpression
Returns according to flag an adaptor specific string for use in a CREATE TABLE statement. The returned string indicates whether a column allows null values. EOSQLExpression's implementation returns the empty string if flag is true, "NOT NULL" otherwise. A subclass should override this if its database server's semantics are different.
Overrides:
allowsNullClauseForConstraint in class EOSQLExpression
Following copied from class: com.webobjects.eoaccess.EOSQLExpression
Parameters:
flag - boolean for whether or not columan allows NULL
Returns:
a SQL string that indicates whether a column allows null values, in the correct adaptor format
See Also:
EOSQLExpression.addCreateClauseForAttribute(EOAttribute anEOAttribute)

appendItemToListString

protected void appendItemToListString(String sqlString)

appendItemToOrderByString

protected void appendItemToOrderByString(String sqlString)

appendItemToValueListString

protected void appendItemToValueListString(String sqlString)

bindVariableDictionaryForAttribute

public NSMutableDictionary bindVariableDictionaryForAttribute(EOAttribute att,
                                                              Object value)
Description copied from class: EOSQLExpression
Implemented by subclasses to create and return the bind variable dictionary for attribute and value. The dictionary returned from this method must contain the following key-value pairs:

Key Corresponding Value
BindVariableNameKey Name of the bind variable for attribute
BindVariablePlaceHolderKey Placeholder string used in the SQL statement
BindVariableAttributeKey attribute
BindVariableValueKey value

An adaptor subclass may define additional entries as required by its RDBMS.

Invoked from sqlStringForValue when the message mustUseBindVariableForAttribute returns true or when the receiver's class uses bind variables and the message shouldUseBindVariableForAttribute returns true.

A subclass that uses bind variables should implement this method without invoking EOSQLExpression's implementation. The subclass implementation must return a dictionary with entries for the keys listed above and may add additional keys.
Overrides:
bindVariableDictionaryForAttribute in class EOSQLExpression
Following copied from class: com.webobjects.eoaccess.EOSQLExpression
Parameters:
attribute - the EOAttribute associated with the bind variable dictionary
value - the value associated with the bind variable dictionary
Returns:
the bind variable dictionary for attribute and value
See Also:
EOSQLExpression.useBindVariables(), EOSQLExpression.sqlStringForValue(Object value, String keyPath), EOSQLExpression.mustUseBindVariableForAttribute(EOAttribute attribute), EOSQLExpression.shouldUseBindVariableForAttribute(EOAttribute attribute), EOSQLExpression

columnTypeStringForAttribute

public String columnTypeStringForAttribute(EOAttribute attribute)
Description copied from class: EOSQLExpression
Returns an adaptor specific type string for attribute that's suitable for use in a CREATE TABLE statement. EOSQLExpression's implementation creates a string based on anAttribute's externalType, precision, and width as follows:

If Condition Generated String
precision is non-zero externalType(precision, scale)
precision is zero and width is non-zero externalType(scale)
precision and width are zero externalType

A subclass should override the default implementation if its database server requires column types in a different format.

Overrides:
columnTypeStringForAttribute in class EOSQLExpression
Following copied from class: com.webobjects.eoaccess.EOSQLExpression
Parameters:
attribute - the EOAttribute associated with adaptor specific type string
Returns:
an adaptor specific type string for attribute
See Also:
(EOAttribute anEOAttribute)

externalNameQuoteCharacter

public String externalNameQuoteCharacter()
Description copied from class: EOSQLExpression
Returns a String with the character used to quote SQL identifiers that use unusual characters which would not otherwise be legal.
Overrides:
externalNameQuoteCharacter in class EOSQLExpression
Following copied from class: com.webobjects.eoaccess.EOSQLExpression
Returns:
the String '\"' (an escaped quote character) if the receiver uses quoted external names, or the empty string ("") otherwise
See Also:
EOSQLExpression.sqlStringForSchemaObjectName(String aString)

formatValueForAttribute

public String formatValueForAttribute(Object value,
                                      EOAttribute attribute)
Description copied from class: EOSQLExpression
This method should be overridden by subclasses to return a string representation of value suitable for use in an SQL statement, depending on attribute's externalType. For example, a subclass might format a date using a special database-specific syntax or standard form or truncate numbers to attribute's precision and scale. EOSQLExpression's implementation merely returns the string representation of value.
Overrides:
formatValueForAttribute in class EOSQLExpression
Following copied from class: com.webobjects.eoaccess.EOSQLExpression
Parameters:
value - an object to be used in a SQL statement
attribute - an EOAttribute to be used in influencing the format
Returns:
a formatted string
See Also:
EOAttribute

jdbcInfo

protected NSDictionary jdbcInfo()

lockClause

public String lockClause()
Description copied from class: EOSQLExpression
Overridden by subclasses to return the SQL string used in a SELECT statement to lock selected rows. A concrete subclass of EOSQLExpression must override this method to return the string used by its adaptor's RDBMS.
Overrides:
lockClause in class EOSQLExpression
Following copied from class: com.webobjects.eoaccess.EOSQLExpression
Returns:
SQL string used in a SELECT statement to lock selected rows

mustUseBindVariableForAttribute

public boolean mustUseBindVariableForAttribute(EOAttribute att)
Description copied from class: EOSQLExpression
Returns true if the receiver must use bind variables for attribute, false otherwise. EOSQLExpression's implementation returns false. An SQL expression subclass that uses bind variables should override this method to return true if the underlying RDBMS requires that bind variables be used for attributes with attribute's external type.
Overrides:
mustUseBindVariableForAttribute in class EOSQLExpression
Returns:
always true for JDBC

prepareSelectExpressionWithAttributes

public void prepareSelectExpressionWithAttributes(NSArray attributes,
                                                  boolean lock,
                                                  EOFetchSpecification fetchSpec)
Description copied from class: EOSQLExpression
Generates a SELECT statement. It is done by performing the following steps:
  1. Invokes addSelectListAttribute for each entry in attributes to prepare the comma-separated list of attributes.
  2. Use fetchSpec's qualifier to generate the receiver's whereClauseString}.
  3. Invokes addOrderByAttributeOrdering for each EOAttributeOrdering object in fetchSpec. First conjoins the qualifier in fetchSpec with the restricting qualifier, if any, of the receiver's entity.
  4. Invokes joinExpression to generate the receiver's joinClauseString.
  5. Invokes tableListWithRootEntity to get the comma-separated list of tables for the FROM clause.
  6. If flag lock is true, invokes lockClause to get the SQL string to lock selected rows.
  7. Invokes assembleSelectStatementWithAttributes.
Overrides:
prepareSelectExpressionWithAttributes in class EOSQLExpression
Following copied from class: com.webobjects.eoaccess.EOSQLExpression
Parameters:
attributes - specifies array of attributes
lock - specifies flag
fetchSpec - specifies fetch specification
See Also:
EOSQLExpressionFactory.selectStatementForAttributes(NSArray attributes, boolean bool, EOFetchSpecification fetchSpec, EOEntity entity), EOSQLExpression.assembleSelectStatementWithAttributes(NSArray attributes, boolean lock, EOQualifier qualifier, NSArray fetchOrder, String selectString, String columnList, String tableList, String whereClause, String joinClause, String orderByClause, String lockClause), EOSQLExpression.addSelectListAttribute(EOAttribute anEOAttribute), EOSQLExpression.whereClauseString(), EOSQLExpression.addOrderByAttributeOrdering(EOSortOrdering sortOrdering), EOSQLExpression.joinExpression(), EOSQLExpression.joinClauseString(), EOSQLExpression.tableListWithRootEntity(EOEntity entity), EOSQLExpression.lockClause()

setJDBCInfo

protected void setJDBCInfo(NSDictionary jdbcInfo)

shouldUseBindVariableForAttribute

public boolean shouldUseBindVariableForAttribute(EOAttribute att)
Description copied from class: EOSQLExpression
Returns true if the receiver can provide a bind variable dictionary for attribute, false otherwise. Bind variables aren't used for values associated with this attribute when useBindVariables returns false. EOSQLExpression's implementation returns false. An SQL expression subclass should override this method to return true if the receiver should use bind variables for attributes with attribute's external type. It should also return true for any attribute for which the receiver must use bind variables.
Overrides:
shouldUseBindVariableForAttribute in class EOSQLExpression
Returns:
always true for JDBC

useBindVariables

public boolean useBindVariables()
Description copied from class: EOSQLExpression
Queries if instances use bind variables. By default, instances don't; if the value for the System property "EOAdaptorUseBindVariables" is "true", instances do use them.
Overrides:
useBindVariables in class EOSQLExpression
Returns:
always true for JDBC

Last updated Fri Feb 21 13:15:00 PST 2003.

Copyright © 2003 Apple Computer, Inc.