EOQualifierSQLGeneration
Adopted by: EOAndQualifier, EOKeyComparisonQualifier, EOKeyValueQualifier, EONotQualifier, EOOrQualifier, EOSQLQualifier
Declared in: EOAccess/EOSQLQualifier.h
Protocol Description
The EOQualifierSQLGeneration protocol declares two methods that are adopted by qualifier classes to qualify fetches from a database. One of the methods, schemaBasedQualifierWithRootEntity:, is used to provide a qualifier suitable for evaluation by a database from a qualifier suitable for in-memory evaluation. The other method, sqlStringForSQLExpression:, is used by concrete subclasses of EOSQLExpression to generate WHERE clauses for SQL statements.
Instance Methods
sqlStringForSQLExpression:
- (NSString *)sqlStringForSQLExpression:(EOSQLExpression
*)sqlExpression
See Also: whereClauseString ( EOSQLExpression)
schemaBasedQualifierWithRootEntity:
- (EOQualifier *)schemaBasedQualifierWithRootEntity:(EOEntity
*)entity
Whereas in-memory qualifier evaluation uses pointers to resolve relationships, a database qualifier must use foreign keys. For example, consider the qualifier below that is used to fetch all employees who work in a specified department:
Department *dept; // Assume this exists. EOQualifier *qualifier; qualifier = [EOQualifier qualifierWithQualifierFormat:@"department = %@", dept];
For an in-memory search, the Framework queries employee objects for their department object and includes an employee in the result list if its department object is equal to dept. (See the EOQualifierEvaluation protocol description for more information on in-memory searching.)
For a database search, the Framework needs to qualify the fetch by specifying a foreign key value for dept. The Framework sends qualifier a schemaBasedQualifierWithRootEntity: message that creates and returns a new qualifier. Assume that the entity for employee objects has an attribute named departmentID and that the primary key value for dept is 459, the resulting qualifier specifies the search conditions as:
department.departmentID = 459See Also: selectObjectsWithFetchSpecification:editingContext: ( EODatabaseChannel)