WebObjects 5.2.3

com.webobjects.eoaccess
Class EOSQLExpressionFactory

java.lang.Object
  extended bycom.webobjects.eoaccess.EOSQLExpressionFactory
Direct Known Subclasses:
JDBCExpressionFactory

public class EOSQLExpressionFactory
extends Object

EOSQLExpressionFactory builds SQL statements for adaptor channels. You don't typically use instances of EOSQLExpression; rather, you use EOSQLExpression subclasses written to work with a particular RDBMS 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're creating a concrete adaptor, you won't ordinarily need to interact with EOSQLExpression objects yourself. You most commonly create and use an EOSQLExpression object when you want to send an SQL statement directly to the server. In this case, you simply create an expression with the EOSQLExpression class method expressionForString, and send the expression object to an adaptor channel using EOAdaptorChannel's evaluateExpression method.

See Also:
expressionForString(String)

Constructor Summary
EOSQLExpressionFactory(EOAdaptor adaptor)
          Creates an EOSQLExpressionFactory capable of creating EOSQLExpressions for the specified EOAdaptor.
 
Method Summary
 EOAdaptor adaptor()
          Returns the EOAdaptor for which this factory creates expressions.
 EOSQLExpression createExpression(EOEntity entity)
          Creates a new instance of the factory's EOSQLExpression class and assigns the parameter entity to that expression.
 EOSQLExpression deleteStatementWithQualifier(EOQualifier qualifier, EOEntity entity)
          Creates and returns an SQL DELETE expression to delete the rows described by qualifier.
 Class expressionClass()
          Returns the subclass of EOSQLExpression used by this factory to create expressions
 EOSQLExpression expressionForEntity(EOEntity entity)
          Creates a new instance of the factory's EOSQLExpression class and assigns the parameter entity to that expression.
 EOSQLExpression expressionForString(String string)
          Creates and returns an SQL expression containing the string parameter.
 EOSQLExpression insertStatementForRow(NSDictionary row, EOEntity entity)
          Creates and returns an SQL INSERT expression to insert row.
 EOSQLExpression selectStatementForAttributes(NSArray attributes, boolean yn, EOFetchSpecification fetchSpec, EOEntity entity)
          Creates and returns an SQL SELECT expression.
 EOSQLExpression updateStatementForRow(NSDictionary row, EOQualifier qualifier, EOEntity entity)
          Creates and returns an SQL UPDATE expression to update the row identified by qualifier with the values in row.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EOSQLExpressionFactory

public EOSQLExpressionFactory(EOAdaptor adaptor)
Creates an EOSQLExpressionFactory capable of creating EOSQLExpressions for the specified EOAdaptor.

Parameters:
adaptor - the adaptor for which EOSQLExpressions are to be created
Method Detail

adaptor

public EOAdaptor adaptor()
Returns the EOAdaptor for which this factory creates expressions.

Returns:
An instance of EOAdaptor for which this factory creates expressions

createExpression

public EOSQLExpression createExpression(EOEntity entity)
Creates a new instance of the factory's EOSQLExpression class and assigns the parameter entity to that expression.

Parameters:
entity - the EOEntity to which the EOSQLExpression is assigned
Returns:
The EOSQLExpression created

deleteStatementWithQualifier

public EOSQLExpression deleteStatementWithQualifier(EOQualifier qualifier,
                                                    EOEntity entity)
Creates and returns an SQL DELETE expression to delete the rows described by qualifier.

Creates an instance of EOSQLExpression, initializes it with entity (an EOEntity object), and sends it a prepareDeleteExpressionForQualifier message.

The expression created with this method does not use table aliases because Enterprise Objects Framework assumes that all INSERT, UPDATE, and DELETE statements are single-table operations. To generate INSERT statements that do use table aliases, you must override prepareInsertExpressionWithRow to send a setUseAliases(true) message prior to invoking super's version.

Parameters:
entity - the EOEntity from which the row will be deleted
qualifier - an EOQualifier identifying the row to be deleted
Returns:
The new EOSQLExpression

expressionClass

public Class expressionClass()
Returns the subclass of EOSQLExpression used by this factory to create expressions

Returns:
The class to by this factory to create expressions

expressionForEntity

public EOSQLExpression expressionForEntity(EOEntity entity)
Creates a new instance of the factory's EOSQLExpression class and assigns the parameter entity to that expression. It is the same as createExpression.

Parameters:
entity - the EOEntity to which the EOSQLExpression is assigned
Returns:
The EOSQLExpression
See Also:
createExpression(EOEntity)

expressionForString

public EOSQLExpression expressionForString(String string)
Creates and returns an SQL expression containing the string parameter.

Parameters:
string - the string from which the expression should be created
Returns:
The EOSQLExpression

insertStatementForRow

public EOSQLExpression insertStatementForRow(NSDictionary row,
                                             EOEntity entity)
Creates and returns an SQL INSERT expression to insert row. Creates an instance of EOSQLExpression, initializes it with entity, and sends it prepareInsertExpressionWithRow(). Raises an IllegalArgumentException if entity is null.

The expression created with this method does not use table aliases because Enterprise Objects Framework assumes that all INSERT, UPDATE, and DELETE statements are single-table operations. To generate INSERT statements that do use table aliases, you must override prepareInsertExpressionWithRow to send a setUseAliases(true) message prior to invoking super's version.

Parameters:
row - an NSDictionary containing column name (key) to value (value) mappings
entity - the EOEntity into which the row will be inserted
Returns:
The new EOSQLExpression

selectStatementForAttributes

public EOSQLExpression selectStatementForAttributes(NSArray attributes,
                                                    boolean yn,
                                                    EOFetchSpecification fetchSpec,
                                                    EOEntity entity)
Creates and returns an SQL SELECT expression.

Creates an instance of EOSQLExpression, initializes it with entity, and sends it prepareSelectExpressionWithAttributes. The expression created with this method uses table aliases.

Raises an IllegalArgumentException if attributes is null or empty, fetchSpecification is null, or entity is null.

The expression created with this method uses table aliases. To generate SELECT statements that doesn't use them, you must override prepareSelectExpressionWithAttributes() to send a setUseAliases(false) message prior to invoking super's version.

Parameters:
attributes -
entity - the EOEntity against which the select will run
fetchSpec - the EOFetchSpecification describing the row(s) to be fetched
yn - boolean specifying whether (true) or not (false) shared locks should be held
Returns:
The new EOSQLExpression

updateStatementForRow

public EOSQLExpression updateStatementForRow(NSDictionary row,
                                             EOQualifier qualifier,
                                             EOEntity entity)
Creates and returns an SQL UPDATE expression to update the row identified by qualifier with the values in row. row should only contain entries for values that have actually changed. Creates an instance of EOSQLExpression, initializes it with entity, and sends it prepareUpdateExpressionWithRow.

Raises an IllegalArgumentException if any parameter is null.

The expression created with this method does not use table aliases because Enterprise Objects Framework assumes that all INSERT, UPDATE, and DELETE statements are single-table operations. To generate INSERT statements that do use table aliases, you must override prepareInsertExpressionWithRow to send a setUseAliases(true) message prior to invoking super's version.

Parameters:
row - an NSDictionary containing column name (key) to value (value) mappings
entity - the EOEntity in which the row will be updated
qualifier - an EOQualifier identifying the row to be updated
Returns:
The new EOSQLExpression

Last updated Thu Oct 21 15:04:16 PDT 2004.

Copyright © 2004 Apple Computer, Inc.