EOAdaptorChannel
Inherits from: NSObject
Package: com.apple.yellow.webobjects
Class Description
EOAdaptorChannel is an abstract class that provides its concrete subclasses with a structure for performing database operations. It's associated with EOAdaptor and EOAdaptorContext, which, together with EOAdaptorChannel, form the adaptor level of Enterprise Objects Framework's access layer. See the EOAdaptor class specification for more information about accessing, creating, and using adaptor level objects.
A concrete subclass of EOAdaptorChannel provides database-specific method implementations and represents an independent communication channel to the database server to which its EOAdaptor object is connected. You never interact with instances of the EOAdaptorChannel class, rather your Enterprise Objects Framework applications use instances of concrete subclasses that are written to interact with a specific database or other persistent storage system.
EOAdaptorChannel isn't declared to be abstract, but conceptually it is abstract. Never create instances of the EOAdaptorChannel class. |
Method | Description |
openChannel | Opens the channel so it can perform database operations. |
closeChannel | Close the channel. |
selectAttributes | Selects rows matching the specified qualifier. |
fetchRow | Fetches a row resulting from the last selectAttributes, executeStoredProcedure, or evaluateExpression. |
insertRow | Inserts the specified row. |
updateValuesInRowsDescribedByQualifier | Updates the row described by the specified qualifier. |
deleteRowDescribedByQualifier | Deletes the row described by the specified qualifier. |
executeStoredProcedure | Performs the specified stored procedure. |
evaluateExpression | Sends the specified expression to the database. |
Method | Description |
openChannel | Opens the channel so it can perform database operations. |
closeChannel | Close the channel. |
selectAttributes | Selects rows matching the specified qualifier. |
fetchRow | Fetches a row resulting from the last selectAttributes, executeStoredProcedure, or evaluateExpression. |
insertRow | Inserts the specified row. |
updateValuesInRowDescribedByQualifier | Updates the row described by the specified qualifier. |
deleteRowDescribedByQualifier | Deletes the row described by the specified qualifier. |
executeStoredProcedure | Performs the specified stored procedure. |
evaluateExpression | Sends the specified expression to the database. |
performAdaptorOperation | Performs an adaptor operation by invoking the EOAdaptorChannel method appropriate for performing the specified operation. |
For more information on subclassing EOAdaptorChannel, see "Creating an EOAdaptorChannel Subclass" .
Constants
EOAdaptorChannel defines several String constants for use as keys and values in an exception's userInfo dictionary (see performAdaptorOperations).
Constant | Description |
AdaptorOperationsKey | A userInfo dictionary key. |
FailedAdaptorOperationKey | A userInfo dictionary key. |
AdaptorFailureKey | A userInfo dictionary key. |
AdaptorOptimisticLockingFailure | A userInfo dictionary value. |
Method Types
- Accessing the adaptor context
- adaptorContext
- Opening and closing a channel
- openChannel
- closeChannel
- isOpen
- Modifying rows
- insertRow
- updateValuesInRowDescribedByQualifier
- updateValuesInRowsDescribedByQualifier
- deleteRowDescribedByQualifier
- deleteRowsDescribedByQualifier
- lockRowComparingAttributes
- Fetching rows
- selectAttributes
- describeResults
- setAttributesToFetch
- attributesToFetch
- fetchRow
- dictionaryWithObjectsForAttributes
- cancelFetch
- isFetchInProgress
- Invoking stored procedures
- executeStoredProcedure
- returnValuesForLastStoredProcedureInvocation
- Assigning primary keys
- primaryKeyForNewRowWithEntity
- Sending SQL to the server
- evaluateExpression
- Batch processing operations
- performAdaptorOperation
- performAdaptorOperations
- Accessing schema information
- describeTableNames
- describeStoredProcedureNames
- addStoredProceduresNamed
- describeModelWithTableNames
- Debugging
- setDebugEnabled
- isDebugEnabled
- Accessing the delegate
- delegate
- setDelegate
Constructors
EOAdaptorChannel
public EOAdaptorChannel(EOAdaptorContext adaptorContext)
Don't invoke this method directly unless you are implementing a concrete adaptor context. It is invoked automatically from createAdaptorChannel-the EOAdaptorContext method you use to create a new adaptor channel.
See Also: adaptorContext
Instance Methods
adaptorContext
public EOAdaptorContext adaptorContext()
See Also: EOAdaptorChannel constructor
addStoredProceduresNamed
public void addStoredProceduresNamed(
NSArray storedProcedureNames,
EOModel model)
attributesToFetch
public NSArray attributesToFetch()
cancelFetch
public void cancelFetch()
An adaptor channel subclass should override this method without invoking EOAdaptorChannel's implementation.
closeChannel
public void closeChannel()
An adaptor channel subclass should override this method without invoking EOAdaptorChannel's implementation.
See Also: cancelFetch, hasOpenTransaction (EOAdaptorContext)
delegate
public Object delegate()
deleteRowDescribedByQualifier
public void deleteRowDescribedByQualifier(
com.apple.yellow.eocontrol.EOQualifier qualifier,
EOEntity entity)
deleteRowsDescribedByQualifier
public int deleteRowsDescribedByQualifier(
com.apple.yellow.eocontrol.EOQualifier qualifier,
EOEntity entity)
- The adaptor channel isn't open.
- The adaptor channel is in an invalid state (for example, it's fetching).
- An error occurs in the database server.
An adaptor channel subclass should override this method without invoking EOAdaptorChannel's implementation.
See Also: deleteRowDescribedByQualifier, isOpen, isFetchInProgress, hasOpenTransaction (EOAdaptorContext)
describeModelWithTableNames
public EOModel describeModelWithTableNames(NSArray tableNames)
EOAdaptorChannel's implementation does nothing. An adaptor channel subclass should override this method to create a default model from the database's metadata.
describeResults
public NSArray describeResults()
An adaptor channel subclass should override this method without invoking EOAdaptorChannel's implementation.
describeStoredProcedureNames
public NSArray describeStoredProcedureNames()
describeTableNames
public NSArray describeTableNames()
EOAdaptorChannel's implementation simply returns null. An adaptor channel subclass should override this method to construct an array of table names from database metadata.
dictionaryWithObjectsForAttributes
public NSMutableDictionary dictionaryWithObjectsForAttributes(
Object[] objects,
NSArray attributes)
A subclass of EOAdaptorChannel shouldn't override this method.
evaluateExpression
public void evaluateExpression(EOSQLExpression expression)
If expression results in a select operation being performed, you can fetch the results as you would if you had sent a selectAttributes. You must use the method setAttributesToFetch before you begin fetching. Also, if expression evaluates to multiple result sets, you must invoke setAttributesToFetch: before you begin fetching each subsequent set.
evaluateExpression: invokes the delegate methods adaptorChannelShouldEvaluateExpression and adaptorChannelDidEvaluateExpression.
An adaptor channel subclass should override this method without invoking EOAdaptorChannel's implementation. Note, however, that the upper layers of the Framework never invoke evaluateExpression directly. Thus, adaptors for data stores that don't naturally support an expression language (for example, flat file adaptors) don't need to implement this method to work with the Framework.
See Also: fetchRow
executeStoredProcedure
public void executeStoredProcedure(
EOStoredProcedure storedProcedure,
NSDictionary values)
An adaptor channel subclass should override this method without invoking EOAdaptorChannel's implementation. Note, however, that the upper layers of the Framework never invoke executeStoredProcedure directly. Thus, adaptors for data stores that don't support stored procedures (for example, flat file adaptors) don't need to implement this method to work with the Framework
fetchRow
public NSMutableDictionary fetchRow()
An adaptor channel subclass should override this method without invoking EOAdaptorChannel's implementation.
See Also: setAttributesToFetch
insertRow
public void insertRow(
NSDictionary row,
EOEntity entity)
- The user logged in to the database doesn't have permission to insert a new row.
- The adaptor channel is in an invalid state (for example, fetching).
- The row fails to satisfy a constraint defined in the database server.
An adaptor channel subclass should override this method without invoking EOAdaptorChannel's implementation.
isDebugEnabled
public boolean isDebugEnabled()
See Also: setDebugEnabled (EOAdaptorContext)
isFetchInProgress
public boolean isFetchInProgress()
- It's been sent a successful selectAttributes message.
- A stored procedure that returns rows has been successfully executed using executeStoredProcedure.
- An expression sent through evaluateExpression: resulted in a select operation being performed.
An adaptor channel stops fetching when there are no more records to fetch or when it's sent a cancelFetch message.
An adaptor channel subclass should override this method without invoking EOAdaptorChannel's implementation.
See Also: fetchRow
isOpen
public boolean isOpen()
See Also: closeChannel
lockRowComparingAttributes
public void lockRowComparingAttributes(
NSArray attributes,
EOEntity entity,
com.apple.yellow.eocontrol.EOQualifier qualifier,
NSDictionary snapshot)
lockRowComparingAttributes invokes selectAttributes with attributes as the attributes to select, a fetch specification built from qualifier, locking on, and entity as the entity. If the select returns no rows or more than one row, the method throws an exception. It also throws an exception if the values in the returned row don't match the corresponding values in snapshot.
The Framework uses this method whenever it needs to lock a row. When the Framework invokes it, qualifier specifies the primary key of the row to be locked and attributes used for locking to be compared in the database server. If any of the values specified in qualifier are different from the values in the database row, the select operation will not retrieve or lock the row. When this happens, the row to be locked has been updated in the database since it was last retrieved, and it isn't safe to update it.
Some attributes (such as BLOB types) can't be compared in the database. attributes should specify any such attributes. (If the row doesn't contain any such attributes, attributes can be null.) If qualifier generates a select statement that returns and locks a single row, this method performs an in-memory comparison between the value in the retrieved row and the value in snapshot for each attribute in attributes. Therefore, snapshot must contain an entry for each attribute in attributes. In addition, it must contain an entry for the row's primary key.
A subclass of EOAdaptorChannel doesn't need to override this method.
openChannel
public void openChannel()
See Also: isOpen, closeChannel
performAdaptorOperation
public void performAdaptorOperation(EOAdaptorOperation adaptorOperation)
A subclass of EOAdaptorChannel doesn't need to override this method.
See Also: performAdaptorOperations
performAdaptorOperations
public void performAdaptorOperations(NSArray adaptorOperations)
This method throws an exception if an error occurs. The exception's userInfo dictionary contains these keys:
Constant | The corresponding value in the exception's userInfo dictionary |
AdaptorOperationsKey |
An array of the EOAdaptorOperations being executed. |
FailedAdaptorOperationKey | The particular EOAdaptorOperation that failed. |
AdaptorFailureKey |
If present, offers additional information on the
type of error that occurred. Currently, the only possible value
for this key is AdaptorOptimisticLockingFailure ,
which indicates that an update or lock operation failed because the
row found in the database did not match the snapshot taken when
the row was last fetched into the application. |
A subclass of EOAdaptorChannel doesn't need to override the performAdaptorOperations method.
primaryKeyForNewRowWithEntity
public NSDictionary primaryKeyForNewRowWithEntity(EOEntity entity)
If information in entity specifies an adaptor-specific means to assign a new primary key (for example, a sequence name or stored procedure), then this method returns a new primary key. Otherwise, if the key is a simple integer, the method tries to fetch a new primary key from the database using an adaptor-specific scheme. Otherwise, the method returns null.
EOAdaptorChannel's implementation simply returns null. See your adaptor channel's documentation for information on how it generates primary keys.
A subclass of EOAdaptorChannel must override this method. For example, to return a value generated by a sequence, you'd create the proper SQL statement (using EOSQLExpression's expressionForString method) and evaluate it (using the evaluateExpression method).
returnValuesForLastStoredProcedureInvocation
public NSDictionary returnValuesForLastStoredProcedureInvocation()
An adaptor channel subclass should override this method without invoking EOAdaptorChannel's implementation.
selectAttributes
public void selectAttributes(
NSArray attributes,
EOFetchSpecification fetchSpecification,
boolean flag,
EOEntity entity)
- The adaptor channel is in an invalid state (for example, fetching).
- The database failed to lock the specified rows.
An adaptor channel subclass should override this method without invoking EOAdaptorChannel's implementation.
See Also: setAttributesToFetch
setAttributesToFetch
public void setAttributesToFetch(NSArray attributes)
An adaptor channel subclass should override this method without invoking EOAdaptorChannel's implementation.
See Also: selectAttributes
setDebugEnabled
public void setDebugEnabled(boolean flag)
A subclass of EOAdaptorChannel doesn't need to override this method. A subclass that does override it must incorporate the superclass's version through a message to super.
See Also: setDebugEnabled (EOAdaptorContext)
setDelegate
public void setDelegate(Object delegate)
updateValuesInRowDescribedByQualifier
public void updateValuesInRowDescribedByQualifier(
NSDictionary values,
com.apple.yellow.eocontrol.EOQualifier qualifier,
EOEntity entity)
A subclass of EOAdaptorChannel doesn't need to override this method.
updateValuesInRowsDescribedByQualifier
public int updateValuesInRowsDescribedByQualifier(
NSDictionary values,
com.apple.yellow.eocontrol.EOQualifier qualifier,
EOEntity entity)
- The user logged in to the database doesn't have permission to update.
- The adaptor channel is in an invalid state (for example, fetching).
- The new values fail to satisfy a constraint defined in the database server.
An adaptor channel subclass should override this method without invoking EOAdaptorChannel's implementation.
See Also: updateValuesInRowDescribedByQualifier