PATH |
EODatabaseContext.Delegate
(informal interface)
Package: com.webobjects.eoaccess
Interface Description
An EODatabaseContext shares its delegate with its EODatabaseChannels. These delegate methods are actually sent from EODatabaseChannel, but they're defined in EODatabaseContext for ease of access:
You can use the EODatabaseContext delegate methods to intervene when objects are created and when they're fetched from the database. This gives you more fine-grained control over such issues as how an object's primary key is generated ( databaseContextNewPrimaryKey), how and if objects are locked ( databaseContextShouldLockObjectWithGlobalID), what fetch specification is used to fetch objects ( databaseContextShouldSelectObjects), how batch faulting is performed ( databaseContextShouldFetchArrayFault and databaseContextShouldFetchObjectFault), and so on. For more information, see the individual delegate method descriptions.
Instance Methods
databaseContextDidFetchObjects
public abstract void databaseContextDidFetchObjects( EODatabaseContext aDatabaseContext, NSArray objects, com.webobjects.eocontrol.EOFetchSpecification fetchSpecification, com.webobjects.eocontrol.EOEditingContext anEditingContext)
See Also: databaseContextShouldFetchObjectFault
databaseContextDidSelectObjects
public abstract void databaseContextDidSelectObjects( EODatabaseContext aDatabaseContext, com.webobjects.eocontrol.EOFetchSpecification fetchSpecification, EODatabaseChannel channel)
See Also: databaseContextShouldSelectObjects
databaseContextFailedToFetchObject
public abstract boolean databaseContextFailedToFetchObject( EODatabaseContext aDatabaseContext, Object object, com.webobjects.eocontrol.EOGlobalID globalID)
true
, aDatabaseContext assumes that the delegate has handled the situation to its satisfaction, in whatever way it deemed appropriate (for example, by displaying an alert panel or initializing a fault object with new values). If it returns false
or if the delegate method is not implemented, aDatabaseContext tracks the globalID of the offending object. If the tracked globalID is in the list of updated objects when prepareForSaveWithCoordinator is invoked, aDatabaseContext throws an exception.
To get a list of the objects that failed to fetch, see the method missingObjectGlobalIDs.
databaseContextNewPrimaryKey
public abstract NSDictionary databaseContextNewPrimaryKey( EODatabaseContext aDatabaseContext, Object object, EOEntity anEntity)
null
, then aDatabaseContext will send an EOAdaptorChannel a primaryKeyForNewRowWithEntity message in an attempt to generate the key.
The dictionary you return from this delegate method contains the attribute or attributes (if object has a compound primary key) that make up object's primary key.
databaseContextShouldFetchArrayFault
public abstract boolean databaseContextShouldFetchArrayFault( EODatabaseContext databaseContext, Object fault)
false
, or return true
to allow the databaseContext to do the fetch itself. If databaseContext performs the fetch it will batch fault according to the batch count on the relationship being fetched.
See Also: databaseContextShouldFetchObjectFault
databaseContextShouldFetchObjectFault
public abstract boolean databaseContextShouldFetchObjectFault( EODatabaseContext databaseContext, Object fault)
false
, or return true
to allow databaseContext to perform the fetch. If databaseContext performs the fetch, it will batch fault according to the batch count on the entity being fetched.
See Also: databaseContextShouldFetchArrayFault
databaseContextShouldFetchObjects
public abstract NSArray databaseContextShouldFetchObjects( EODatabaseContext aDatabaseContext, com.webobjects.eocontrol.EOFetchSpecification fetchSpecification, com.webobjects.eocontrol.EOEditingContext anEditingContext)
null
, aDatabaseContext performs the fetch. Otherwise, the returned array is returned as the fetch result.
See Also: databaseContextDidFetchObjects
databaseContextShouldInvalidateObjectWithGlobalID
public abstract boolean databaseContextShouldInvalidateObjectWithGlobalID( EODatabaseContext aDatabaseContext, com.webobjects.eocontrol.EOGlobalID globalID, NSDictionary snapshot)
false
.
databaseContextShouldLockObjectWithGlobalID
public abstract boolean databaseContextShouldLockObjectWithGlobalID( EODatabaseContext aDatabaseContext, com.webobjects.eocontrol.EOGlobalID globalID, NSDictionary snapshot)
true
if it wants the operation to proceed or false
if it doesn't. Values from snapshot are used to create a qualifier from the attributes used for locking specified for the object's entity (that is, the object identified by globalID). Delegates can override the locking mechanism by implementing their own locking procedure and returning false
. Methods that override the locking mechanism should throw an exception on the failure to lock exactly one object.
databaseContextShouldRaiseExceptionForLockFailure
public abstract boolean databaseContextShouldRaiseExceptionForLockFailure( EODatabaseContext aDatabaseContext, Throwable exception)
databaseContextShouldSelectObjects
public abstract boolean databaseContextShouldSelectObjects( EODatabaseContext aDatabaseContext, com.webobjects.eocontrol.EOFetchSpecification fetchSpecification, EODatabaseChannel channel)
true
the channel will go ahead and select the object; if the delegate returns false
(possibly after issuing custom SQL against the adaptor) the channel will skip the select and return.
databaseContextShouldUpdateCurrentSnapshot
public abstract NSDictionary databaseContextShouldUpdateCurrentSnapshot( EODatabaseContext aDatabaseContext, NSDictionary currentSnapshot, NSDictionary newSnapshot, com.webobjects.eocontrol.EOGlobalID globalID, EODatabaseChannel channel)
EOObjectsChangedInStoreNotification
, causing the object store hierarchy to invalidate existing objects (as identified by globalID) built from the obsolete snapshot. You can use this method to achieve the same effect as using a EOFetchSpecification with setRefreshesRefetchedObjects: set to true
-that is, it allows you to overwrite in-memory object values with values from the database that may have been changed by someone else.
Returning currentSnapshot (or null
) causes the aDatabaseContext to perform the default behavior (that is, not updating the older snapshot).
databaseContextShouldUsePessimisticLock
public abstract boolean databaseContextShouldUsePessimisticLock( EODatabaseContext databaseContext, com.webobjects.eocontrol.EOFetchSpecification fetchSpecification, EODatabaseChannel channel)
true
the channel locks the rows being selected; if the delegate returns false
the channel selects the rows without locking.
databaseContextWillFireArrayFaultForGlobalID
public abstract void databaseContextWillFireArrayFaultForGlobalID( EODatabaseContext dbContext, com.webobjects.eocontrol.EOGlobalID globalID, EORelationship relationship, com.webobjects.eocontrol.EOFetchSpecification fetchSpec, com.webobjects.eocontrol.EOEditingContext edContext)
Note: It is very dangerous to modify the fetch specification. |
databaseContextWillFireObjectFaultForGlobalID
public abstract void databaseContextWillFireObjectFaultForGlobalID( EODatabaseContext dbContext, com.webobjects.eocontrol.EOGlobalID globalID, com.webobjects.eocontrol.EOFetchSpecification fetchSpec, com.webobjects.eocontrol.EOEditingContext edContext)
Note: It is very dangerous to modify the fetch specification. |
databaseContextWillOrderAdaptorOperations
public abstract NSArray databaseContextWillOrderAdaptorOperations( EODatabaseContext aDatabaseContext, NSArray databaseOperations)
databaseContextWillPerformAdaptorOperations
public abstract NSArray databaseContextWillPerformAdaptorOperations( EODatabaseContext aDatabaseContext, NSArray adaptorOperations, EOAdaptorChannel adaptorChannel)
databaseContextWillRunLoginPanelToOpenDatabaseChannel
public abstract boolean databaseContextWillRunLoginPanelToOpenDatabaseChannel( EODatabaseContext aDatabaseContext, NSArray adaptorOperations, EOAdaptorChannel adaptorChannel)
© 2001 Apple Computer, Inc. (Last Published April 13, 2001)