WebObjects 5.2

com.webobjects.eoaccess
Class EOSQLExpression

java.lang.Object
  |
  +--com.webobjects.eoaccess.EOSQLExpression
Direct Known Subclasses:
JDBCExpression

public abstract class EOSQLExpression
extends Object

EOSQLExpression is an abstract superclass that defines how to build SQL statements for adaptor channels. You don't typically use instances of EOSQLExpression; rather, you can use EOSQLExpression subclasses written to work with a particular RDBMS (relational database management system) and corresponding adaptor. A concrete subclass of EOSQLExpression overrides many of its methods in terms of the query language syntax for its specific RDBMS. EOSQLExpression objects are used internally by the Framework, and unless you are creating a concrete adaptor, you won't ordinarily need to interact with EOSQLExpression objects itself. You would create and use an EOSQLExpression object when you want to send a SQL statement directly to the server. In this case, you simply create an expression with the EOSQLExpressionFactory's method expressionForString, and send that expression object to an adaptor channel using EOAdaptorChannel's method evaluateExpression. See EOSQLExpression Concepts for more information.


Inner Class Summary
static interface EOSQLExpression.SQLValue
          This interface defines API for objects that can provide values for themselves to be used in SQL statements.
 
Field Summary
static String BindVariableAttributeKey
          A key for the attribute that uses the bind variable.
static String BindVariableColumnKey
          A key for the column name to be used in SQL.
static String BindVariableNameKey
          The key for the name of a bind variable.
static String BindVariablePlaceHolderKey
          A key for the placeholder string to be used in SQL.
static String BindVariableValueKey
          A key for the value of the bind variable.
 
Constructor Summary
EOSQLExpression(EOEntity entity)
          Creates a new EOSQLExpression rooted to an EOEntity.
 
Method Summary
 void addBindVariableDictionary(NSDictionary binding)
          Adds binding to this object's array of bind variable dictionaries.
 void addCreateClauseForAttribute(EOAttribute attribute)
          Adds the SQL string for creating attribute to a comma-separated list of attribute creation clauses.
 void addInsertListAttribute(EOAttribute attribute, Object value)
          Adds the SQL string for attribute to a comma-separated list of attributes and value to a comma-separated list of values.
 void addJoinClause(String leftName, String rightName, int semantic)
          Creates a new join clause by invoking assembleJoinClause and adds it to the receiver's join clause string.
 void addOrderByAttributeOrdering(EOSortOrdering sortOrdering)
          Adds an attribute-direction pair ("LAST_NAME asc", for example) to the receiver's ORDER BY string.
 void addSelectListAttribute(EOAttribute attribute)
          Adds a SQL string for attribute to a comma-separated list of attribute names for use in a SELECT statement.
 void addUpdateListAttribute(EOAttribute attribute, Object value)
          Adds an attribute-value assignment ("LAST_NAME = 'Thomas'", for example) to a comma-separated list for use in an UPDATE statement.
 NSMutableDictionary aliasesByRelationshipPath()
          Returns a dictionary of table aliases.
 String allowsNullClauseForConstraint(boolean flag)
          Returns according to flag an adaptor specific string for use in a CREATE TABLE statement.
 void appendItemToListString(String itemString, StringBuffer listString)
          Adds itemString to a comma-separated list.
 String assembleDeleteStatementWithQualifier(EOQualifier qualifier, String tableList, String whereClause)
          This method is invoked from prepareDeleteExpressionForQualifier to return an SQL DELETE statement.
 String assembleInsertStatementWithRow(NSDictionary row, String tableList, String columnList, String valueList)
          This method is invoked from prepareInsertExpressionWithRow to return an SQL INSERT statement.
 String assembleJoinClause(String leftName, String rightName, int semantic)
          This method is invoked from addJoinClause to return a JOIN clause.
 String assembleSelectStatementWithAttributes(NSArray attributes, boolean lock, EOQualifier qualifier, NSArray fetchOrder, String selectString, String columnList, String tableList, String whereClause, String joinClause, String orderByClause, String lockClause)
          This method is invoked from prepareSelectExpressionWithAttributes to return an SQL SELECT statement.
 String assembleUpdateStatementWithRow(NSDictionary row, EOQualifier qualifier, String tableList, String updateList, String whereClause)
          This method is invoked from prepareUpdateExpressionWithRow to return an SQL UPDATE statement.
 NSArray bindVariableDictionaries()
          Returns the bind variable dictionaries.
abstract  NSMutableDictionary bindVariableDictionaryForAttribute(EOAttribute attribute, 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.
 EOEntity entity()
          Returns the receiver's entity.
 String externalNameQuoteCharacter()
          Returns a String with the character used to quote SQL identifiers that use unusual characters which would not otherwise be legal.
 String formatSQLString(String sqlString, String format)
          Applies the format specified by format to a SQL string sqlString.
 String formatStringValue(String string)
          Formats string for use as a string constant in a SQL statement.
 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.
 String joinClauseString()
          Returns the part of the receiver's WHERE clause that specifies join conditions.
 void joinExpression()
          Builds up the joinClauseString for use in a SELECT statement.
 String listString()
          Returns a comma-separated list of attributes or "attribute = value" assignments.
 String lockClause()
          Overridden by subclasses to return the SQL string used in a SELECT statement to lock selected rows.
 boolean mustUseBindVariableForAttribute(EOAttribute attribute)
          Returns true if the receiver must use bind variables for attribute, false otherwise.
 String orderByString()
          Returns the comma-separated list of "attribute direction" pairs ("LAST_NAME asc, FIRST_NAME asc", for example) for use in a SELECT statement.
 void prepareConstraintStatementForRelationship(EORelationship relationship, NSArray sourceColumns, NSArray destinationColumns)
          Sets the receiver's statement to an adaptor specific constraint for relationship.
 void prepareDeleteExpressionForQualifier(EOQualifier qualifier)
          Generates a DELETE statement.
 void prepareInsertExpressionWithRow(NSDictionary row)
          Generates an INSERT statement.
 void prepareSelectExpressionWithAttributes(NSArray attributes, boolean lock, EOFetchSpecification fetchSpec)
          Generates a SELECT statement.
 void prepareUpdateExpressionWithRow(NSDictionary row, EOQualifier qualifier)
          Generates an UPDATE statement.
 void setStatement(String statement)
          Sets the receiver's SQL statement to statement, which should be a valid expression in the target query language.
 void setUseAliases(boolean useAliases)
          Tells the receiver whether or not to use table aliases.
 void setUseBindVariables(boolean flag)
          Sets according to flag whether all instances of EOSQLExpression subclasses use bind variables.
static void setUseQuotedExternalNames(boolean bool)
          Deprecated. This static method is inappropriate in Java. Subclasses should implement their own policy on quoting identifiers.
 boolean shouldUseBindVariableForAttribute(EOAttribute attribute)
          Returns true if the receiver can provide a bind variable dictionary for attribute, false otherwise.
 char sqlEscapeChar()
          Returns the char used for the ESCAPE clause in an SQL LIKE expression.
 String sqlPatternFromShellPattern(String pattern)
          Translates a "like" qualifier to an SQL LIKE expression.
 String sqlPatternFromShellPatternWithEscapeCharacter(String pattern, char escapeChar)
          Like sqlPatternFromShellPattern except that escapeCharacter allows you to specify a character for escaping the SQL wild card characters "%" and "_".
 String sqlStringForAttribute(EOAttribute attribute)
          Returns the SQL string for attribute, complete with a table alias if the receiver uses table aliases.
 String sqlStringForAttributeNamed(String name)
          Returns the SQL string for the attribute name, complete with a table alias if the receiver uses table aliases.
 String sqlStringForAttributePath(NSArray path)
          Returns the SQL string for path, complete with a table alias if the receiver uses table aliases.
 String sqlStringForCaseInsensitiveLike(String valueString, String keyString)
          Overridden by subclasses to return a case insensitive comparison of valueString and keyString.
 String sqlStringForConjoinedQualifiers(NSArray qualifiers)
          Creates and returns an SQL string that is the result of interposing the word "AND" between the SQL strings for the qualifiers in qualifiers.
 String sqlStringForData(NSData data)
          Returns the SQL string for a data of type NSData.
 String sqlStringForDisjoinedQualifiers(NSArray qualifiers)
          Creates and returns a SQL string that is the result of interposing the word "OR" between the SQL strings for the qualifiers in qualifiers.
 String sqlStringForKeyComparisonQualifier(EOKeyComparisonQualifier qualifier)
          Creates and returns a SQL string that is the result of interposing an operator between the SQL strings for the right and left keys in qualifier.
 String sqlStringForKeyValueQualifier(EOKeyValueQualifier qualifier)
          Creates and returns a SQL string that is the result of interposing an operator between the SQL strings for qualifier's key and value.
 String sqlStringForNegatedQualifier(EOQualifier qualifier)
          Creates and returns a SQL string that is the result of surrounding the SQL string for qualifier in parentheses and appending it to the word "not".
static String sqlStringForNumber(Number number)
          Returns the SQL string for number.
 String sqlStringForQualifier(EOQualifierSQLGeneration qualifier)
          Returns a SQL statement for qualifier suitable for inclusion in a WHERE clause.
 String sqlStringForSchemaObjectName(String name)
          Returns name enclosed in the external name quote character if the receiver uses quoted external names, otherwise simply returns name unaltered.
 String sqlStringForSelector(NSSelector selector, Object value)
          Returns a SQL operator for selector and value.
static String sqlStringForString(String string)
          Returns the SQL string for string.
 String sqlStringForValue(Object value, String keyPath)
          Returns a string for value appropriate for use in an SQL statement.
 String statement()
          An SQL statement can be assigned to an EOSQLExpression object directly using expressionForString or using setStatement.
 String tableListWithRootEntity(EOEntity entity)
          Returns the comma-separated list of tables for use in a SELECT, UPDATE, or DELETE statement's FROM clause.
 String toString()
          Returns a readable description of the SQL expression.
 boolean useAliases()
          Returns true if the receiver generates statements with table aliases, false otherwise.
 boolean useBindVariables()
          Queries if instances use bind variables.
static boolean useQuotedExternalNames()
          Deprecated. This static method is inappropriate in Java. Subclasses should implement their own policy on quoting identifiers.
 String valueList()
          Returns the comma-separated list of values used in an INSERT statement.
 String whereClauseString()
          Returns the part of the receiver's WHERE clause that qualifies rows.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BindVariableAttributeKey

public static final String BindVariableAttributeKey
A key for the attribute that uses the bind variable.
See Also:
bindVariableDictionaryForAttribute(com.webobjects.eoaccess.EOAttribute, java.lang.Object)

BindVariableColumnKey

public static final String BindVariableColumnKey
A key for the column name to be used in SQL.
See Also:
bindVariableDictionaryForAttribute(com.webobjects.eoaccess.EOAttribute, java.lang.Object)

BindVariableNameKey

public static final String BindVariableNameKey
The key for the name of a bind variable.
See Also:
bindVariableDictionaryForAttribute(com.webobjects.eoaccess.EOAttribute, java.lang.Object)

BindVariablePlaceHolderKey

public static final String BindVariablePlaceHolderKey
A key for the placeholder string to be used in SQL.
See Also:
bindVariableDictionaryForAttribute(com.webobjects.eoaccess.EOAttribute, java.lang.Object)

BindVariableValueKey

public static final String BindVariableValueKey
A key for the value of the bind variable.
See Also:
bindVariableDictionaryForAttribute(com.webobjects.eoaccess.EOAttribute, java.lang.Object)
Constructor Detail

EOSQLExpression

public EOSQLExpression(EOEntity entity)
Creates a new EOSQLExpression rooted to an EOEntity.
Parameters:
entity - an EOEntity
See Also:
EOEntity
Method Detail

addBindVariableDictionary

public void addBindVariableDictionary(NSDictionary binding)
Adds binding to this object's array of bind variable dictionaries. binding is generally created using bindVariableDictionaryForAttribute and is added to the bind variable dictionaries in sqlStringForValue when this receiver uses a bind variable for the specified attribute.
Parameters:
binding - specifies binding to the object array
See Also:
bindVariableDictionaries(), bindVariableDictionaryForAttribute( EOAttribute attribute, Object value), sqlStringForValue(Object value, String keyPath), EOSQLExpression

addCreateClauseForAttribute

public void addCreateClauseForAttribute(EOAttribute attribute)
Adds the SQL string for creating attribute to a comma-separated list of attribute creation clauses. The list is constructed for use in a CREATE TABLE statement produced by createTableStatementsForEntityGroup. One can use listString to access the creation clauses.

EOSQLExpression's implementation creates clauses in the following form:

                 COLUMN_NAME COLUMN_TYPE ALLOWS_NULL_CLAUSE
 
Where

Parameters:
attribute - an EOAttribute
See Also:
listString(), columnTypeStringForAttribute(EOAttribute anEOAttribute), allowsNullClauseForConstraint(boolean aBoolean), EOSchemaGeneration.createTableStatementsForEntityGroup(NSArray entityGroup), EOAttribute.allowsNull()

addInsertListAttribute

public void addInsertListAttribute(EOAttribute attribute,
                                   Object value)
Adds the SQL string for attribute to a comma-separated list of attributes and value to a comma-separated list of values. Both lists are constructed for use in an INSERT statement. You can use the methods listString and valueList to access the attributes and value lists.

Invokes appendItemToListString to add an SQL string for attribute to the receiver's listString, and again to add a formatted SQL string for value to the receiver's valueList.

Parameters:
attribute - an EOAttribute to be added
value - an value of object to be added
See Also:
listString(), valueList(), appendItemToListString(String aString, StringBuffer aStringBuffer), sqlStringForAttribute(EOAttribute anEOAttribute), sqlStringForValue(Object value, String keyPath), formatValueForAttribute(Object value, EOAttribute attribute)

addJoinClause

public void addJoinClause(String leftName,
                          String rightName,
                          int semantic)
Creates a new join clause by invoking assembleJoinClause and adds it to the receiver's join clause string. Separates join conditions already in the join clause string with the word "and". Invoked from joinExpression.
Parameters:
leftName - specifies name at left
rightName - specifies name at right
semantic - properties of join
See Also:
joinClauseString(), assembleJoinClause(String aString, String aString, int anInt), joinExpression()

addOrderByAttributeOrdering

public void addOrderByAttributeOrdering(EOSortOrdering sortOrdering)
Adds an attribute-direction pair ("LAST_NAME asc", for example) to the receiver's ORDER BY string. If sortOrdering's selector is EOSortOrdering.CompareCaseInsensitiveAscending or EOSortOrdering.CompareCaseInsensitiveAscending, the string generated has the format "upper(attribute) direction". Method orderByString can be used to access the ORDER BY string. This method invokes appendItemToListString to add the attribute-direction pair.
Parameters:
sortOrdering - the kind of sort ordering wanted
See Also:
orderByString(), appendItemToListString(String aString, StringBuffer aStringBuffer), sqlStringForAttributeNamed(String name), EOSortOrdering

addSelectListAttribute

public void addSelectListAttribute(EOAttribute attribute)
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.
Parameters:
attribute - the EOAttribute whose name will be added to listString
See Also:
appendItemToListString(String aString, StringBuffer aStringBuffer), listString(), sqlStringForAttribute(EOAttribute anEOAttribute), formatSQLString(String sqlString, String format), EOAttribute.readFormat()

addUpdateListAttribute

public void addUpdateListAttribute(EOAttribute attribute,
                                   Object value)
Adds an attribute-value assignment ("LAST_NAME = 'Thomas'", for example) to a comma-separated list for use in an UPDATE statement. Formats value with attribute's "write" format. Method listString can be used to access the list. This method invokes appendItemToListString to add the attribute-value assignment.
Parameters:
attribute - the EOAttribute that contributes the left-hand-side of the assignment
value - the value that contributes the right-hand-side of the assignment
See Also:
listString(), appendItemToListString(String aString, StringBuffer aStringBuffer), formatSQLString(String sqlString, String format), EOAttribute.writeFormat()

aliasesByRelationshipPath

public NSMutableDictionary aliasesByRelationshipPath()
Returns a dictionary of table aliases. The keys of the dictionary are relationship paths -- "department" and "department.location", for example. The values are the table aliases for the corresponding table -- "t1" and "t2", for example. The dictionary always has at least one entry: an entry for the EOSQLExpression's entity. The key of this entry is the empty string ("") and the value is "t0". The dictionary returned from this method is built up over time with successive calls to sqlStringForAttributePath.
Returns:
the NSMutableDictionary of table aliases
See Also:
sqlStringForAttributePath(NSArray aNSArray), tableListWithRootEntity(EOEntity entity)

allowsNullClauseForConstraint

public String allowsNullClauseForConstraint(boolean flag)
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.
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:
addCreateClauseForAttribute(EOAttribute anEOAttribute)

appendItemToListString

public void appendItemToListString(String itemString,
                                   StringBuffer listString)
Adds itemString to a comma-separated list. If listString already has entries, this method appends a comma followed by itemString.
Parameters:
itemString - specifies item as string
listString - specifies a comma-separated list of attributes
See Also:
addSelectListAttribute(EOAttribute anEOAttribute), addInsertListAttribute(EOAttribute anEOAttribute, Object anObject), addUpdateListAttribute(EOAttribute attribute, Object value), addOrderByAttributeOrdering(EOSortOrdering sortOrdering)

assembleDeleteStatementWithQualifier

public String assembleDeleteStatementWithQualifier(EOQualifier qualifier,
                                                   String tableList,
                                                   String whereClause)
This method is invoked from prepareDeleteExpressionForQualifier to return an SQL DELETE statement. The statement is of the form:
 DELETE FROM tableList SQL_WHERE whereClause
 

Parameters:
qualifier - an EOQualifier for finding the row to delete the WHERE clause in a particular way
tableList - SQL table list
whereClause - SQL WHERE clause
Returns:
a constructed SQL DELETE statement
See Also:
prepareDeleteExpressionForQualifier(EOQualifier qualifier)

assembleInsertStatementWithRow

public String assembleInsertStatementWithRow(NSDictionary row,
                                             String tableList,
                                             String columnList,
                                             String valueList)
This method is invoked from prepareInsertExpressionWithRow to return an SQL INSERT statement. The statement is of the form:
 INSERT INTO tableList (columnList) VALUES valueList
 
or, if columnList is null:
 INSERT INTO tableList VALUES valueList
 
Parameters:
row - an NSDictionary containing the row data
tablelist - SQL table list
columnList - SQL column list
valueList - SQL value list
Returns:
a constructed SQL INSERT statement
See Also:
prepareInsertExpressionWithRow(NSDictionary row)

assembleJoinClause

public String assembleJoinClause(String leftName,
                                 String rightName,
                                 int semantic)
This method is invoked from addJoinClause to return a JOIN clause. The clause is of the form:
 leftName operator rightName
 
where operator is "=" for an inner join, "*=" for a left-outer join, and "=*" for a right-outer join.
Parameters:
leftName - specifies leftname
rightName - specifies rightname
semantic - specifies semantic
Returns:
a constructed JOIN clause
See Also:
addJoinClause(String aString, String aString, int anInt)

assembleSelectStatementWithAttributes

public String assembleSelectStatementWithAttributes(NSArray attributes,
                                                    boolean lock,
                                                    EOQualifier qualifier,
                                                    NSArray fetchOrder,
                                                    String selectString,
                                                    String columnList,
                                                    String tableList,
                                                    String whereClause,
                                                    String joinClause,
                                                    String orderByClause,
                                                    String lockClause)
This method is invoked from prepareSelectExpressionWithAttributes to return an SQL SELECT statement. The statment is of the form:
 SELECT columnList
 FROM tableList lockClause
 WHERE whereClause AND joinClause
 ORDER BY orderByClause
 
If lockClause is null, it is omitted from the statement. Similarly, if orderByClause is null, the "ORDER BY orderByClause" is omitted. If either whereClause or joinClause is null, the "AND" and null-valued argument are omitted. If both are null, the entire WHERE clause is omitted. attributes, lock, qualifer, fetchOrder arguments to prepareSelectExpressionWithAttributes from which the other assembleSelect... arguments were derived. They are provided for subclasses that need to generate the clauses of the SELECT statement in a particular way.
Parameters:
attributes - an NSArray of attributes
lock - flag for locking rows in database
qualifier - an EOQualifier for selecting rows
fetchOrder - specifies fetch order
selectString - SQL SELECT keyword, possibly with DISTINCT
columnList - SQL column list
tableList - SQL table list
whereClause - SQL WHERE clause
joinClause - specifies join condition to add to WHERE clause
orderByClause - SQL ORDER BY clause
lockClause - specifies clause for lock
Returns:
a constructed SELECT statement
See Also:
prepareSelectExpressionWithAttributes(NSArray attributes, boolean lock, EOFetchSpecification fetchSpec)

assembleUpdateStatementWithRow

public String assembleUpdateStatementWithRow(NSDictionary row,
                                             EOQualifier qualifier,
                                             String tableList,
                                             String updateList,
                                             String whereClause)
This method is invoked from prepareUpdateExpressionWithRow to return an SQL UPDATE statement. The statement is of the form:
 UPDATE tableList
 SET updateList
 WHERE whereClause
 
row and qualifier are the arguments to prepareUpdateExpressionWithRow from which updateList and whereClause were derived. They are provided for subclasses that need to generate the clauses of the UPDATE statement in a particular way.
Parameters:
row - an NSDictionary containing the row data
qualifier - an EOQualifier for finding the row to update
tableList - SQL table list
updateList - SQL update list
whereClause - SQL where clause
Returns:
a constructed SQL UPDATE statement
See Also:
prepareUpdateExpressionWithRow(NSDictionary row, EOQualifier qualifier)

bindVariableDictionaries

public NSArray bindVariableDictionaries()
Returns the bind variable dictionaries.
Returns:
the bind variable dictionaries
See Also:
addBindVariableDictionary(NSDictionary binding), EOSQLExpression(com.webobjects.eoaccess.EOEntity)

bindVariableDictionaryForAttribute

public abstract NSMutableDictionary bindVariableDictionaryForAttribute(EOAttribute attribute,
                                                                       Object value)
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.
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:
useBindVariables(), sqlStringForValue(Object value, String keyPath), mustUseBindVariableForAttribute(EOAttribute attribute), shouldUseBindVariableForAttribute(EOAttribute attribute), EOSQLExpression

columnTypeStringForAttribute

public String columnTypeStringForAttribute(EOAttribute attribute)
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.

Parameters:
attribute - the EOAttribute associated with adaptor specific type string
Returns:
an adaptor specific type string for attribute
See Also:
(EOAttribute anEOAttribute)

entity

public EOEntity entity()
Returns the receiver's entity.
Returns:
the receiver's entity

externalNameQuoteCharacter

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

formatSQLString

public String formatSQLString(String sqlString,
                              String format)
Applies the format specified by format to a SQL string sqlString.
Parameters:
sqlString - the SQL string to be formatted
format - this could be either an EOAttribute's readFormat or writeFormat
Returns:
the formatted string or the original string unchanged if format is null
See Also:
EOAttribute.readFormat(), EOAttribute.writeFormat(), EOAttribute

formatStringValue

public String formatStringValue(String string)
Formats string for use as a string constant in a SQL statement. EOSQLExpression's implementation encloses the string in single quotes, escaping any single quotes already present in string.
Parameters:
string - the string to be formatted
Returns:
the formatted string
Throws:
java.lang.IllegalArgumentException - If string is null

formatValueForAttribute

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

joinClauseString

public String joinClauseString()
Returns the part of the receiver's WHERE clause that specifies join conditions. Together, the joinExpression and the whereClauseString make up a statement's WHERE clause. If the receiver's statement doesn't contain join conditions, this method returns an empty string.

An EOSQLExpression's joinClauseString is generally set by invoking joinExpression.

Returns:
the part of the receiver's WHERE clause that specifies join conditions
See Also:
joinExpression(), whereClauseString(), whereClauseString()

joinExpression

public void joinExpression()
Builds up the joinClauseString for use in a SELECT statement. For each relationship path in the aliasesByRelationshipPath dictionary, this method invokes addJoinClause for each of the relationship's EOJoin objects.

If the aliasesByRelationshipPath dictionary only has one entry (the entry for the EOSQLExpression's entity), the joinClauseString is empty.

You must invoke this method after invoking addSelectListAttribute for each attribute to be selected and after sending sqlStringForSQLExpression(this) to the qualifier for the SELECT statement. (These methods build up the aliasesByRelationshipPath dictionary by invoking sqlStringForAttributePath.)

See Also:
whereClauseString(), joinClauseString(), aliasesByRelationshipPath(), addJoinClause(String aString, String aString, int anInt), addSelectListAttribute(EOAttribute anEOAttribute), sqlStringForAttributePath(NSArray aNSArray), EOJoin

listString

public String listString()
Returns a comma-separated list of attributes or "attribute = value" assignments. listString is built up with successive invocations of addInsertListAttribute, addSelectListAttribute, or addUpdateListAttribute for INSERT statements, SELECT statements, and UPDATE statements, respectively. The contents of listString vary according to the type of statement the receiver is building:
Type of Statement Sample listString Contents
INSERT FIRST_NAME, LAST_NAME, EMPLOYEE_ID
UPDATE FIRST_NAME = "Timothy", LAST_NAME = "Richardson"
SELECT t0.FIRST_NAME, t0.LAST_NAME, t1.DEPARTMENT_NAME
Returns:
a String containing a comma-separated list of attributes
See Also:
addInsertListAttribute(EOAttribute anEOAttribute, Object anObject), addSelectListAttribute(EOAttribute anEOAttribute), addUpdateListAttribute(EOAttribute attribute, Object value)

lockClause

public String lockClause()
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.
Returns:
SQL string used in a SELECT statement to lock selected rows

mustUseBindVariableForAttribute

public boolean mustUseBindVariableForAttribute(EOAttribute attribute)
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.
Parameters:
attribute - the EOAttribute associated with the bind variable dictionary
Returns:
true if the receiver must use bind variables for attribute
See Also:
shouldUseBindVariableForAttribute(EOAttribute anEOAttribute), bindVariableDictionaryForAttribute(EOAttribute attribute, Object value)

orderByString

public String orderByString()
Returns the comma-separated list of "attribute direction" pairs ("LAST_NAME asc, FIRST_NAME asc", for example) for use in a SELECT statement.
Returns:
the comma-separated list of "attribute direction" pairs ("LAST_NAME asc, FIRST_NAME asc", for example) for use in a SELECT statement
See Also:
addOrderByAttributeOrdering(EOSortOrdering sortOrdering)

prepareConstraintStatementForRelationship

public void prepareConstraintStatementForRelationship(EORelationship relationship,
                                                      NSArray sourceColumns,
                                                      NSArray destinationColumns)
Sets the receiver's statement to an adaptor specific constraint for relationship. EOSQLExpression's implementation generates statements of the form:
 ALTER TABLE TABLE_NAME ADD CONSTRAINT CONSTRAINT_NAME
 FOREIGN KEY (SOURCE_KEY_LIST)
 REFERENCES DESTINATION_TABLE_NAME (DESTINATION_KEY_LIST)
 
Where
Parameters:
relationship - specifies relationship
sourceColumns - specifies array of source columns
destinationColumns - specifies destination columns
See Also:
statement(), EOSchemaGeneration.foreignKeyConstraintStatementsForRelationship(EORelationship relationship)

prepareDeleteExpressionForQualifier

public void prepareDeleteExpressionForQualifier(EOQualifier qualifier)
Generates a DELETE statement. It is done by performing the following steps:
  1. Generates the receiver's whereClauseString.
  2. Invokes tableListWithRootEntity to get the table name for the FROM clause.
  3. Invokes assembleDeleteStatementWithQualifier.
Parameters:
qualifier - the argument to assembleDeleteStatementWithQualifier from which table name for the FROM clause was derived
See Also:
whereClauseString(), tableListWithRootEntity(EOEntity entity), assembleDeleteStatementWithQualifier(EOQualifier qualifier, String tableList, String whereClause), EOSQLExpressionFactory.deleteStatementWithQualifier(EOQualifier qualifier, EOEntity entity), EOSQLExpressionFactory.deleteStatementWithQualifier(EOQualifier qualifier, EOEntity entity)

prepareInsertExpressionWithRow

public void prepareInsertExpressionWithRow(NSDictionary row)
Generates an INSERT statement. It is done by performing the following steps:
  1. Invokes addInsertListAttribute for each entry in row to prepare the comma-separated list of attributes and the corresponding list of values.
  2. Invokes tableListWithRootEntity to get the table name.
  3. Invokes assembleInsertStatementWithRow.

Parameters:
row - specifies row which is to be inserted
See Also:
addInsertListAttribute(EOAttribute anEOAttribute, Object anObject), assembleInsertStatementWithRow(NSDictionary row , String tableList, String columnList, String valueList), tableListWithRootEntity(EOEntity entity), EOSQLExpressionFactory.insertStatementForRow(NSDictionary row, EOEntity entity)

prepareSelectExpressionWithAttributes

public void prepareSelectExpressionWithAttributes(NSArray attributes,
                                                  boolean lock,
                                                  EOFetchSpecification fetchSpec)
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.
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), assembleSelectStatementWithAttributes(NSArray attributes, boolean lock, EOQualifier qualifier, NSArray fetchOrder, String selectString, String columnList, String tableList, String whereClause, String joinClause, String orderByClause, String lockClause), addSelectListAttribute(EOAttribute anEOAttribute), whereClauseString(), addOrderByAttributeOrdering(EOSortOrdering sortOrdering), joinExpression(), joinClauseString(), tableListWithRootEntity(EOEntity entity), lockClause()

prepareUpdateExpressionWithRow

public void prepareUpdateExpressionWithRow(NSDictionary row,
                                           EOQualifier qualifier)
Generates an UPDATE statement. It is done by performing the following steps:
  1. Invokes addUpdateListAttribute for each entry in row to prepare the comma-separated list of "attribute = value" assignments.
  2. Generates the receiver's whereClauseString using qualifer.
  3. Invokes tableListWithRootEntity to get the table name for the FROM clause.
  4. Invokes assembleUpdateStatementWithRow.
Parameters:
row - specifies row in which update will occur
qualifier - specifies qualifier which generates the receiver's whereClauseString
See Also:
EOSQLExpressionFactory.updateStatementForRow( NSDictionary row, EOQualifier qualifier, EOEntity entity), addUpdateListAttribute(EOAttribute attribute, Object value), whereClauseString(), tableListWithRootEntity(EOEntity entity), lockClause(), assembleUpdateStatementWithRow(NSDictionary row, EOQualifier qualifier, String tableList, String updateList, String whereClause)

setStatement

public void setStatement(String statement)
Sets the receiver's SQL statement to statement, which should be a valid expression in the target query language. This method can be used instead of a prepare... method to directly assign an SQL string to an EOSQLExpression object. This method does not perform substitutions or formatting of any kind.
Parameters:
statement - specifies receiver's SQL statement
See Also:
EOSQLExpressionFactory.expressionForString(String string), statement()

setUseAliases

public void setUseAliases(boolean useAliases)
Tells the receiver whether or not to use table aliases.
Parameters:
useAliases - pass in true for affirmation, false otherwise
See Also:
useAliases()

setUseBindVariables

public void setUseBindVariables(boolean flag)
Sets according to flag whether all instances of EOSQLExpression subclasses use bind variables.
Parameters:
flag - a boolean flag to indicate if instances should use bind variables
See Also:
useBindVariables(), EOSQLExpression

setUseQuotedExternalNames

public static void setUseQuotedExternalNames(boolean bool)
Deprecated. This static method is inappropriate in Java. Subclasses should implement their own policy on quoting identifiers.

See Also:
externalNameQuoteCharacter()

shouldUseBindVariableForAttribute

public boolean shouldUseBindVariableForAttribute(EOAttribute attribute)
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.
Parameters:
attribute - the EOAttribute associated with the bind variable dictionary
Returns:
true if the receiver can provide a bind variable dictionary for attribute
See Also:
mustUseBindVariableForAttribute(EOAttribute attribute), useBindVariables()

sqlEscapeChar

public char sqlEscapeChar()
Returns the char used for the ESCAPE clause in an SQL LIKE expression. The default is backslash '\\'. A subclass should return (char)0 if the database doesn't support LIKE...ESCAPE...
Returns:
the ESCAPE char for a LIKE expression

sqlPatternFromShellPattern

public String sqlPatternFromShellPattern(String pattern)
Translates a "like" qualifier to an SQL LIKE expression. Invoked from sqlStringForKeyValueQualifier when the qualifier argument is an EOKeyValueQualifier object whose selector is EOQualifier.QualifierOperatorLike. EOSQLExpression's implementation performs the following substitutions:

Character in pattern Substitution string
* %
? _
% \%
_ \_

Literal '%' and '_' are actually "escaped" using the sqlEscapeChar, typically backslash '\\' as shown.

Parameters:
pattern - qualifier pattern string
Returns:
equivalent pattern string in SQL syntax
See Also:
sqlEscapeChar, sqlStringForKeyValueQualifier, EOKeyValueQualifier

sqlPatternFromShellPatternWithEscapeCharacter

public String sqlPatternFromShellPatternWithEscapeCharacter(String pattern,
                                                            char escapeChar)
Like sqlPatternFromShellPattern except that escapeCharacter allows you to specify a character for escaping the SQL wild card characters "%" and "_".

Parameters:
pattern - specifies pattern to be translated
escapeCharacter - SQL escape character
Returns:
pattern string for SQL "LIKE" expression
See Also:
sqlPatternFromShellPattern(String pattern)

sqlStringForAttribute

public String sqlStringForAttribute(EOAttribute attribute)
Returns the SQL string for attribute, complete with a table alias if the receiver uses table aliases. Invoked from sqlStringForAttributeNamed when the attribute name is not a path.
Parameters:
attribute - specifies EOAttribute corresponding to SQL string
Returns:
the SQL string for attribute
See Also:
sqlStringForAttributeNamed(String name), sqlStringForAttributePath(NSArray aNSArray), useAliases()

sqlStringForAttributeNamed

public String sqlStringForAttributeNamed(String name)
Returns the SQL string for the attribute name, complete with a table alias if the receiver uses table aliases. Generates the return value using sqlStringForAttributePath if name is an attribute path ("department.name", for example); otherwise, uses sqlStringForAttribute.
Parameters:
name - specifies EOAttribute corresponding to SQL string
Returns:
the SQL string for the attribute name
See Also:
sqlStringForAttribute(EOAttribute attribute), sqlStringForAttributePath(NSArray aNSArray)

sqlStringForAttributePath

public String sqlStringForAttributePath(NSArray path)
Returns the SQL string for path, complete with a table alias if the receiver uses table aliases. Invoked from sqlStringForAttributeNamed when the specified attribute name is a path ("department.location.officeNumber", for example). path is an array of any number of EORelationship objects followed by an EOAttribute object. The EORelationship and EOAttribute objects each correspond to a component in path. For example, if the attribute name argument to sqlStringForAttributeNamed is "department.location.officeNumber", path is an array containing the following objects in the order listed:

Assuming that the receiver uses aliases and the alias for the Location table is t2, the SQL string for this sample attribute path is "t2.officeNumber".

If the receiver uses table aliases, this method has the side effect of adding a "relationship path"-"alias name" entry to the aliasesByRelationshipPath dictionary.

Parameters:
path - specify path corresponding to SQL string
Returns:
the SQL string for path
See Also:
sqlStringForAttribute(EOAttribute attribute), sqlStringForAttributeNamed(String name), aliasesByRelationshipPath()

sqlStringForCaseInsensitiveLike

public String sqlStringForCaseInsensitiveLike(String valueString,
                                              String keyString)
Overridden by subclasses to return a case insensitive comparison of valueString and keyString. For example, a subclass implementation might return the string "UPPER(keyString) LIKE UPPER(valueString)".
Parameters:
valueString - specifies valueString
keyString - specifies keyString
Returns:
a case insensitive comparison of valueString and keyString

sqlStringForConjoinedQualifiers

public String sqlStringForConjoinedQualifiers(NSArray qualifiers)
Creates and returns an SQL string that is the result of interposing the word "AND" between the SQL strings for the qualifiers in qualifiers. If the SQL string for a qualifier contains only white space, it isn't included in the return value. The return value is enclosed in parentheses if the SQL strings for two or more qualifiers were ANDed together.
Parameters:
qualifiers - specifies qualifiers
Returns:
a SQL string

sqlStringForData

public String sqlStringForData(NSData data)
Returns the SQL string for a data of type NSData. The default implementation returns the hexadecimal equivalent of data.
Parameters:
data - the NSData to be converted to SQL string
Returns:
the SQL string for an NSData type; the default implementation returns the hexadecimal equivalent of data

sqlStringForDisjoinedQualifiers

public String sqlStringForDisjoinedQualifiers(NSArray qualifiers)
Creates and returns a SQL string that is the result of interposing the word "OR" between the SQL strings for the qualifiers in qualifiers. If the SQL string for a qualifier contains only white space, it isn't included in the return value. The return value is enclosed in parentheses if the SQL strings for two or more qualifiers were ORed together.
Parameters:
qualifiers - specifies qualifiers
Returns:
a SQL string that is the result of interposing the word "OR" between the SQL strings for the qualifiers in qualifiers

sqlStringForKeyComparisonQualifier

public String sqlStringForKeyComparisonQualifier(EOKeyComparisonQualifier qualifier)
Creates and returns a SQL string that is the result of interposing an operator between the SQL strings for the right and left keys in qualifier. Determines the SQL operator by invoking sqlStringForSelector with qualifier's selector and null for the value. Generates SQL strings for qualifier's keys by invoking sqlStringForAttributeNamed to get SQL strings. This method also formats the strings for the right and left keys using formatSQLString with the corresponding attributes' "read" formats.
Parameters:
qualifier - specifies qualifiers
Returns:
an SQL string that is the result of interposing an operator between the SQL strings for the right and left keys in qualifier
See Also:
sqlStringForSelector(NSSelector aNSSelector, Object anObject), sqlStringForAttributeNamed(String name), formatSQLString(String sqlString, String format)

sqlStringForKeyValueQualifier

public String sqlStringForKeyValueQualifier(EOKeyValueQualifier qualifier)
Creates and returns a SQL string that is the result of interposing an operator between the SQL strings for qualifier's key and value. Determines the SQL operator by invoking sqlStringForSelector with qualifier's selector and value. Generates an SQL string for qualifier's key by invoking sqlStringForAttributeNamed to get an SQL string and formatSQLString with the corresponding attribute's "read" format. Similarly, generates an SQL string for qualifier's value by invoking sqlStringForValue to get an SQL string and formatValueForAttribute to format it. (First invokes sqlPatternFromShellPattern for the value if qualifier's selector is EOQualifier.QualifierOperatorLike.)
Parameters:
qualifier - specifies qualifier
Returns:
a SQL string that is the result of interposing an operator between the SQL strings for qualifier's key and value
See Also:
sqlStringForSelector(NSSelector aNSSelector, Object anObject), sqlStringForAttributeNamed(String name), formatSQLString(String sqlString, String format), sqlStringForValue(Object value, String keyPath), formatValueForAttribute(Object value, EOAttribute attribute), sqlPatternFromShellPattern(String pattern)

sqlStringForNegatedQualifier

public String sqlStringForNegatedQualifier(EOQualifier qualifier)
Creates and returns a SQL string that is the result of surrounding the SQL string for qualifier in parentheses and appending it to the word "not". For example, if the string for qualifier is "FIRST_NAME = 'John'", sqlStringForNegatedQualifier returns the string "not (FIRST_NAME = 'John')". If the SQL string for qualifier contains only white space, this method returns null.
Parameters:
qualifier - specifies qualifier
Returns:
a SQL string that is the result of surrounding the SQL string for qualifier in parentheses and appending it to the word "not".

sqlStringForNumber

public static String sqlStringForNumber(Number number)
Returns the SQL string for number.
Parameters:
number - the number to be converted to SQL string
Returns:
the SQL string for number

sqlStringForQualifier

public String sqlStringForQualifier(EOQualifierSQLGeneration qualifier)
Returns a SQL statement for qualifier suitable for inclusion in a WHERE clause. Invoked from an EOSQLExpression while it's preparing a SELECT, UPDATE, or DELETE statement.
Parameters:
qualifier - an EOQualifier
Returns:
a SQL statement for qualifier suitable for inclusion in a WHERE clause
See Also:
whereClauseString()

sqlStringForSchemaObjectName

public String sqlStringForSchemaObjectName(String name)
Returns name enclosed in the external name quote character if the receiver uses quoted external names, otherwise simply returns name unaltered.
Parameters:
name - specifies name
Returns:
name enclosed in the external name quote character if the receiver uses quoted external names otherwise returns name unaltered
See Also:
externalNameQuoteCharacter()

sqlStringForSelector

public String sqlStringForSelector(NSSelector selector,
                                   Object value)
Returns a SQL operator for selector and value. The possible values for selector are defined as constants in EOQualifier. The following table summarizes EOSQLExpression's default mapping:

Selector (EOQualifier constant) SQL Operator
QualifierOperatorEqual "is" if value is NullValue, "=" otherwise
QualifierOperatorNotEqual "is not" if value is NullValue, "<>" otherwise
QualifierOperatorLessThan "<"
QualifierOperatorGreaterThan ">"
QualifierOperatorLessThanOrEqualTo "<="
QualifierOperatorGreaterThanOrEqualTo ">="
QualifierOperatorLike "like"

Parameters:
selector - specifies selector
value - specifies value
Returns:
an SQL operator for selector and value
Throws:
IllegalStateException - if selector is an unknown operator
See Also:
sqlStringForKeyComparisonQualifier(EOKeyComparisonQualifier anEOKeyComparisonQualifier), sqlStringForKeyValueQualifier(EOKeyValueQualifier qualifier), EOQualifier, NSKeyValueCoding.NullValue

sqlStringForString

public static String sqlStringForString(String string)
Returns the SQL string for string.
Parameters:
string - the String to be converted to SQL string
Returns:
the SQL string for string

sqlStringForValue

public String sqlStringForValue(Object value,
                                String keyPath)
Returns a string for value appropriate for use in an SQL statement. If the receiver uses a bind variable for the attribute named keyPath, then sqlStringForValue gets the bind variable dictionary for the attribute, adds it to the receiver's array of bind variables dictionaries, and returns the value for the binding's BindVariablePlaceHolderKey. Otherwise, this method invokes formatValueForAttribute and returns the formatted string for value.
Parameters:
value - specifies value
keyPath - specifies key path
Returns:
a String for value appropriate for use in an SQL statement
See Also:
BindVariablePlaceHolderKey, mustUseBindVariableForAttribute(EOAttribute attribute), shouldUseBindVariableForAttribute(EOAttribute attribute), useBindVariables(), bindVariableDictionaries(), addBindVariableDictionary(NSDictionary binding), formatValueForAttribute(Object value, EOAttribute attribute)

statement

public String statement()
An SQL statement can be assigned to an EOSQLExpression object directly using expressionForString or using setStatement. Generally, however, an EOSQLExpression's statement is built up using one of the following methods:

Returns:
the complete SQL statement
See Also:
setStatement(String aString), EOSQLExpressionFactory.expressionForString(String string), prepareSelectExpressionWithAttributes( NSArray attributes, boolean lock, EOFetchSpecification fetchSpec), prepareInsertExpressionWithRow(NSDictionary row), prepareUpdateExpressionWithRow(NSDictionary row, EOQualifier qualifier), prepareDeleteExpressionForQualifier(EOQualifier qualifier)

tableListWithRootEntity

public String tableListWithRootEntity(EOEntity entity)
Returns the comma-separated list of tables for use in a SELECT, UPDATE, or DELETE statement's FROM clause. If the receiver doesn't use table aliases, the table list consists only of the table name for entity-"EMPLOYEE", for example. If the receiver does use table aliases (only in SELECT statements by default), the table list is a comma separated list of table names and their aliases, for example:
 EMPLOYEE t0, DEPARTMENT t1
 
tableListWithRootEntity creates a string containing the table name for entity and a corresponding table alias ("EMPLOYEE t0", for example). For each entry in aliasesByRelationshipPath, this method appends a new table name and table alias.
Parameters:
entity - specifies receiver's entity
Returns:
the comma-separated list of tables for use in a SELECT, UPDATE, or DELETE statement's FROM clause
See Also:
useAliases(), aliasesByRelationshipPath()

toString

public String toString()
Returns a readable description of the SQL expression.
Overrides:
toString in class Object
Returns:
a readable description of the SQL expression

useAliases

public boolean useAliases()
Returns true if the receiver generates statements with table aliases, false otherwise. For example, the following SELECT statement uses table aliases: SELECT t0.FIRST_NAME, t0.LAST_NAME, t1.NAME FROM EMPLOYEE t0, DEPARTMENT t1 WHERE t0.DEPARTMENT_ID = t1.DEPARTMENT_ID The EMPLOYEE table has the alias t0, and the DEPARTMENT table has the alias t1.

By default, EOSQLExpression uses table aliases only in SELECT statements. Enterprise Objects Framework assumes that INSERT, UPDATE, and DELETE statements are single-table operations.

Returns:
true if the receiver generates statements with table aliases, false otherwise
See Also:
useAliases(), aliasesByRelationshipPath(), EOSQLExpression

useBindVariables

public boolean useBindVariables()
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.
Returns:
true if instances use bind variables, false otherwise
See Also:
setUseBindVariables(boolean flag), EOSQLExpression

useQuotedExternalNames

public static boolean useQuotedExternalNames()
Deprecated. This static method is inappropriate in Java. Subclasses should implement their own policy on quoting identifiers.

See Also:
externalNameQuoteCharacter()

valueList

public String valueList()
Returns the comma-separated list of values used in an INSERT statement. For example, the value list for the following INSERT statement:
 INSERT EMPLOYEE (FIRST_NAME, LAST_NAME, EMPLOYEE_ID, DEPARTMENT_ID, SALARY)
 VALUES ('Shaun', 'Hayes', 1319, 23, 4600)
 
is "'Shaun', 'Hayes', 1319, 23, 4600". An EOSQLExpression's valueList is generated a value at a time with addInsertListAttribute messages.
Returns:
a String containing the comma-separated list of values used in an INSERT statement
See Also:
addInsertListAttribute(EOAttribute anEOAttribute, Object anObject)

whereClauseString

public String whereClauseString()
Returns the part of the receiver's WHERE clause that qualifies rows. The whereClauseString does not specify join conditions; the joinClauseString does that. Together, the whereClauseString and the joinClauseString make up a statement's where clause. For example, a qualifier for an Employee entity specifies that a statement only affects employees who belong to the Finance department and whose monthly salary is greater than $4500. Assume the corresponding where clause looks like this:
 WHERE EMPLOYEE.SALARY > 4500 AND DEPARTMENT.NAME = 'Finance'
       AND EMPLOYEE.DEPARTMENT_ID = DEPARTMENT.DEPARTMENT_ID
 
EOSQLExpression generates both a whereClauseString and a joinClauseString for this qualifier. The whereClauseString qualifies the rows and looks like this:
 EMPLOYEE.SALARY > 4500 AND DEPARTMENT.NAME = 'Finance'
 
The joinClauseString specifies the join conditions between the EMPLOYEE table and the DEPARTMENT table and looks like this:
 EMPLOYEE.DEPARTMENT_ID = DEPARTMENT.DEPARTMENT_ID
 
Returns:
a String cotaining the part of the receiver's WHERE clause that qualifies rows
See Also:
joinClauseString(), whereClauseString(), EOQualifierSQLGeneration

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

Copyright © 2003 Apple Computer, Inc.