Documentation Archive Developer
Search
PATH  Documentation > WebObjects 4.5 > EOAccess Reference

Table of Contents

EODatabaseContext


Inherits from: EOCooperatingObjectStore : EOObjectStore : NSObject
Conforms to: NSObject
(NSObject)
Declared in: EOAccess/EODatabaseContext.h




Class Description


An EODatabaseContext object is an EOObjectStore (EOControl) for accessing relational databases, creating and saving objects based on EOEntity definitions in an EOModel.

An EODatabaseContext represents a single connection to a database server, and it determines the updating and locking strategy used by its EODatabaseChannel objects. An EODatabaseContext has a corresponding EODatabase object. If the server supports multiple concurrent transactions, the EODatabase object may have several database contexts. If the server and adaptor support it, a database context may in turn have several database channels, which handle access to the data on the server.

For a more information on EODatabaseContext, see the sections:




Constants


In EODatabaseContext.h, EOAccess defines an enumeration type, EOUpdateStrategy, to identify update strategies. It's constants and the other constants defined in the EODatabaseContext.h are described in the following table:


Constant Type Description
EOUpdateWithOptimisticLocking EOUpdateStrategy Identifies the locking strategy as optimistic.
EOUpdateWithPessimisticLocking EOUpdateStrategy Identifies the locking strategy as pessimistic
EOUpdateWithNoLocking EOUpdateStrategy Identifies the locking strategy as no locking
EOCustomQueryExpressionHintKey NSString A key in an EOFetchSpecification's hint dictionary
EOStoredProcedureNameHintKey NSString A key in an EOFetchSpecification's hint dictionary
EODatabaseContextKey NSString A key in an EOGenericAdaptorException's userInfo dictionary
EODatabaseOperationsKey NSString A key in an EOGenericAdaptorException's userInfo dictionary
EOFailedDatabaseOperationKey NSString A key in an EOGenericAdaptorException's userInfo dictionary

In addition, EODatabaseContext defines a constant for the name of the notification it posts. For more information on the notification, see "Notifications" .



Method Types


Initializing instances
- initWithDatabase:
Fetching objects
- objectsWithFetchSpecification:editingContext:
- objectsForSourceGlobalID:relationshipName:editingContext:
- arrayFaultWithSourceGlobalID:relationshipName:editingContext:
- faultForGlobalID:editingContext:
- faultForRawRow:entityNamed:editingContext:
- batchFetchRelationship:forSourceObjects:editingContext:
- missingObjectGlobalIDs
Enabling shared object loading
+ setSharedObjectLoadingEnabled:
+ isSharedObjectLoadingEnabled
Accessing the adaptor context
- adaptorContext
Managing the database connection
+ forceConnectionWithModel:connectionDictionaryOverrides:editingContext:
- handleDroppedConnection
Accessing the database object
- database
Accessing the coordinator
- coordinator
Managing channels
- availableChannel
- registerChannel:
- registeredChannels
- unregisterChannel:
- hasBusyChannels
Accessing the delegate
- setDelegate:
- delegate
+ setDefaultDelegate:
+ defaultDelegate
Committing or discarding changes
- saveChangesInEditingContext:
- invalidateAllObjects
- invalidateObjectsWithGlobalIDs:
- rollbackChanges
- commitChanges
- prepareForSaveWithCoordinator:editingContext:
- recordUpdateForObject:changes:
- recordChangesInEditingContext
- refaultObject:withGlobalID:editingContext:
Determining if the EODatabaseContext is responsible for a particular operation
- ownsObject:
- ownsGlobalID:
- handlesFetchSpecification:
Recording snapshots
- recordSnapshot:forGlobalID:
- recordSnapshots:
- recordSnapshot:forSourceGlobalID:relationshipName:
- recordToManySnapshots:
Forgetting snapshots
- forgetSnapshotForGlobalID:
- forgetSnapshotsForGlobalIDs:
Accessing snapshots
- localSnapshotForGlobalID:
- localSnapshotForSourceGlobalID:relationshipName:
- snapshotForGlobalID:after:
- snapshotForGlobalID:
- snapshotForSourceGlobalID:relationshipName:after:
- snapshotForSourceGlobalID:relationshipName:
Initializing objects
- initializeObject:withGlobalID:editingContext:
Obtaining an EODatabaseContext
+ registeredDatabaseContextForModel:editingContext:
Locking objects
- setUpdateStrategy:
- updateStrategy
- registerLockedObjectWithGlobalID:
- isObjectLockedWithGlobalID:
- isObjectLockedWithGlobalID:editingContext:
- forgetAllLocks
- forgetLocksForObjectsWithGlobalIDs:
- lockObjectWithGlobalID:editingContext:
Returning information about objects
- valuesForKeys:object:
Setting the context class
+ contextClassToRegister
+ setContextClassToRegister:
Thread safety
- lock
- unlock


Class Methods



contextClassToRegister

+ (Class)contextClassToRegister

Returns the class that is registered with an EOObjectStoreCoordinator when the coordinator broadcasts an EOCooperatingObjectStoreNeeded notification. By default this is EODatabaseContext, but you can use setContextClassToRegister: to specify your own subclass of EODatabaseContext.

When an EOObjectStoreCoordinator sends an EOCooperatingObjectStoreNeeded notification for an EOEntity in the default model group, if contextClassToRegister is non-nil (and it should be-it makes no sense to set contextClassToRegister to nil), an instance of the that class is created, the EOModel for the EOEntity is registered, and the context class is registered with the requesting EOObjectStoreCoordinator.



defaultDelegate

+ (id)defaultDelegate

Returns the default delegate-the object assigned as delegate to new EODatabaseContext instances.

forceConnectionWithModel:connectionDictionaryOverrides:editingContext:

+ (EODatabaseContext *)forceConnectionWithModel:(EOModel *)amodel connectionDictionaryOverrides:(NSDictionary *)overrides editingContext:(EOEditingContext *)anEditingContext

Forces the stack of objects in the EOAccess layer to be instantiated, if necessary, and then makes a connection to the database. If there is an existing connection for amodel, it is first closed and then reconnected. The new connection dictionary is effectively made up of the model's connection dictionary, overlaid with overrides. All compatible models in the model's group also are associated with the new connection (so they share the same adaptor). Returns the EODatabaseContext associated with the model for anEditingContext.

isSharedObjectLoadingEnabled

+ (BOOL)isSharedObjectLoadingEnabled

Returns YES if database contexts automatically load enterprise objects into the default shared editing context when they load models; NO otherwise. The objects loaded into the shared editing context are those identified by entities' shared fetch specifications.

See Also: - sharedObjectFetchSpecificationNames ( EOEntity)



registeredDatabaseContextForModel:editingContext:

+ (EODatabaseContext *)registeredDatabaseContextForModel:(EOModel *)aModel editingContext:(EOEditingContext *)anEditingContext

Finds the EOObjectStoreCoordinator (EOControl) for anEditingContext and checks to see if it already contains an EODatabaseContext cooperating store for aModel. If it does, it returns that EODatabaseContext. Otherwise it instantiates a new EODatabaseContext, adds it to the EOObjectStoreCoordinator, and returns the EODatabaseContext.

setContextClassToRegister:

+ (void)setContextClassToRegister:(Class)contextClass

Sets to contextClass the "contextClassToRegister." For more discussion of this topic, see the method description for contextClassToRegister.

setDefaultDelegate:

+ (void)setDefaultDelegate:(id)defaultDelegate

Sets the default delegate to defaultDelegate-the object assigned as delegate to new instances of EODatabaseContext.

setSharedObjectLoadingEnabled:

+ (void)setSharedObjectLoadingEnabled:(BOOL)flag

Sets according to flag whether database contexts automatically load enterprise objects into the default shared editing context when they load models. The default is YES (the database automatically loads shared objects). The objects loaded into the shared editing context are those identified by entities' shared fetch specifications.

See Also: - sharedObjectFetchSpecificationNames ( EOEntity)




Instance Methods



adaptorContext

- (EOAdaptorContext *)adaptorContext

Returns the EOAdaptorContext used by the EODatabaseContext for communication with the database server.

arrayFaultWithSourceGlobalID:relationshipName:editingContext:

- (NSArray *)arrayFaultWithSourceGlobalID:(EOGlobalID *)globalID relationshipName:(NSString *)name editingContext:(EOEditingContext *)anEditingContext

Overrides the inherited implementation to create a to-many fault for anEditingContext. name must correspond to an EORelationship in the EOEntity for the specified globalID.

See Also: - faultForGlobalID:editingContext:



availableChannel

- (EODatabaseChannel *)availableChannel

Returns an EODatabaseChannel that's registered with the receiver and that isn't busy. If the method can't find a channel that meets these criteria, it posts an EODatabaseChannelNeededNotification in the hopes that someone will provide a new channel. After posting the notification, the receiver checks its list of channels again. If there are still no available channels, the receiver creates an EODatabaseChannel itself. However, if the list is not empty and there are no available channels, the method returns nil.

See Also: - registerChannel:, - registeredChannels, - unregisterChannel:



batchFetchRelationship:forSourceObjects:editingContext:

- (void)batchFetchRelationship:(EORelationship *)relationship forSourceObjects:(NSArray *)objects editingContext:(EOEditingContext *)anEditingContext

Clear all the faults for the relationship of anEditingContext's objects and performs a single, efficient, fetch (at most two fetches, if the relationship is many-to-many). This method provides a way to fetch the same relationship for multiple objects. For example, given an array of Employee objects, this method can fetch all of their departments with one round trip to the server, rather than asking the server for each of the employee's departments individually.

commitChanges

- (void)commitChanges

Overrides the inherited implementation to instruct the adaptor to commit the transaction. If the commit is successful, any primary and foreign key changes are written back to the saved objects, database locks are released, and an EOCooperatingObjectStoreNeeded (defined in EOControl's EOObjectStore) is posted describing the committed changes. Raises an exception if the adaptor is unable to commit the transaction; the error message indicates the nature of the problem. You should never need to invoke this method directly.

See Also: - ownsGlobalID:, - rollbackChanges



coordinator

- (EOObjectStoreCoordinator *)coordinator

Returns the receiver's EOObjectStoreCoordinator (EOControl) or nil if there is none. This method is only valid during a save operation.

database

- (EODatabase *)database

Returns the receiver's EODatabase.

See Also: - initWithDatabase:



delegate

- (id)delegate

Returns the receiver's delegate.

See Also: - setDelegate:



faultForGlobalID:editingContext:

- (id)faultForGlobalID:(EOGlobalID *)globalID editingContext:(EOEditingContext *)anEditingContext

Overrides the inherited implementation to create a to-one fault for the object identified by globalID and register it in anEditingContext.

See Also: - arrayFaultWithSourceGlobalID:relationshipName:editingContext:



faultForRawRow:entityNamed:editingContext:

- (id <EOEnterpriseObject>)faultForRawRow:(id)row entityNamed:(NSString *)entityName editingContext:(EOEditingContext *)context

Returns a fault for a raw row. row is the raw data, typically in the form of an NSDictionary. entityName is the name of the appropriate entity for the EO you want to create (as a fault). editingContext is the EOEditingContext in which to create the fault

forgetAllLocks

- (void)forgetAllLocks

Clears all of the receiver's locks. Doesn't cause the locks to be forgotten in the server, only in the receiver. This method is useful when something has happened to cause the server to forget the locks and the receiver needs to be synced up. This method is invoked whenever a transaction is committed or rolled back.

See Also: - registerLockedObjectWithGlobalID:, - isObjectLockedWithGlobalID:, - isObjectLockedWithGlobalID:editingContext:, - forgetLocksForObjectsWithGlobalIDs:, - lockObjectWithGlobalID:editingContext:, - lockObject: (EOEditingContext)



forgetLocksForObjectsWithGlobalIDs:

- (void)forgetLocksForObjectsWithGlobalIDs:(NSArray *)globalIDs

Clears the locks made for the enterprise objects identified by each of the EOGlobalIDs in globalIDs. Doesn't cause the locks to be forgotten in the server, only in the receiver.

See Also: - registerLockedObjectWithGlobalID:, - isObjectLockedWithGlobalID:, - isObjectLockedWithGlobalID:editingContext:, - forgetAllLocks, - lockObjectWithGlobalID:editingContext:, - lockObject: (EOEditingContext)



forgetSnapshotForGlobalID:

- (void)forgetSnapshotForGlobalID:(EOGlobalID *)globalID

Deletes the snapshot made for the enterprise object identified by globalID.

See Also: - recordSnapshot:forGlobalID:, - localSnapshotForGlobalID:, - recordSnapshots:, - snapshotForGlobalID:, - forgetSnapshotsForGlobalIDs:



forgetSnapshotsForGlobalIDs:

- (void)forgetSnapshotsForGlobalIDs:(NSArray *)globalIDs

Deletes the snapshots made for the enterprise objects identified by globalIDs, an array of EOGlobalID objects.

See Also: - recordSnapshot:forGlobalID:, - localSnapshotForGlobalID:, - recordSnapshots:, - snapshotForGlobalID:



handleDroppedConnection

- (void)handleDroppedConnection

Cleans up after a database connection is dropped by releasing the receiver's adaptor context and database channels, and then creating a new adaptor context. Don't invoke this method; it's invoked automatically by the Framework.

handlesFetchSpecification:

- (BOOL)handlesFetchSpecification:(EOFetchSpecification *)fetchSpec

Overrides the inherited implementation to return YES if the receiver is responsible for fetching the objects described by the entity name in fetchSpec.

See Also: - ownsObject:, - ownsGlobalID:



hasBusyChannels

- (BOOL)hasBusyChannels

Returns YES if the receiver's EOAdaptorContext has channels that have outstanding operations (that is, have a fetch in progress), NO otherwise.

initializeObject:withGlobalID:editingContext:

- (void)initializeObject:(id)object withGlobalID:(EOGlobalID *)globalID editingContext:(EOEditingContext *)anEditingContext

Overrides the inherited implementation initialize object for anEditingContext by filling it with properties based on row data fetched from the adaptor. The snapshot for globalID is looked up and those attributes in the snapshot that are marked as class properties in the EOEntity are assigned to object. For relationship class properties, faults are constructed and assigned to the object.

initWithDatabase:

- initWithDatabase:(EODatabase *)aDatabase

Initializes a newly allocated EODatabaseContext with aDatabase as the EODatabase object it works with. The new EODatabaseContext retains aDatabase. Returns self, or nil if unable to create another EOAdaptorContext for the EOAdaptor of aDatabase. This is the designated initializer for the EODatabaseContext class.

invalidateAllObjects

- (void)invalidateAllObjects

Overrides the inherited implementation to discard all snapshots in the receiver's EODatabase, forget all locks, and post an EOInvalidatedAllObjectsInStoreNotification, as well as an EOObjectsChangedInStoreNotification with the invalidated global IDs in the userInfo dictionary. Both of these notifications are defined in EOObjectStore (EOControl). This method works by invoking - invalidateObjectsWithGlobalIDs: for all of the snapshots in the receiver's EODatabase.

invalidateObjectsWithGlobalIDs:

- (void)invalidateObjectsWithGlobalIDs:(NSArray *)globalIDs

Overrides the inherited implementation to discard the snapshots for the objects identified by the EOGlobalIDs in globalIDs and broadcasts an EOObjectsChangedInStoreNotification (defined in EOObjectStore), which causes the EOEditingContext containing objects fetched from the receiver to refault those objects. The result is that these objects will be refetched from the database the next time they're accessed.

isObjectLockedWithGlobalID:

- (BOOL)isObjectLockedWithGlobalID:(EOGlobalID *)globalID

Returns YES if the enterprise object identified by globalID is locked, NO otherwise.

See Also: - registerLockedObjectWithGlobalID:, - forgetAllLocks, - isObjectLockedWithGlobalID:editingContext:, - forgetLocksForObjectsWithGlobalIDs:, - lockObjectWithGlobalID:editingContext:, - lockObject: (EOEditingContext)



isObjectLockedWithGlobalID:editingContext:

- (BOOL)isObjectLockedWithGlobalID:(EOGlobalID *)globalID editingContext:(EOEditingContext *)anEditingContext

Overrides the EOObjectStore method isObjectLockedWithGlobalID:editingContext: to return YES if the database row corresponding to globalID has been locked in an open transaction held by the receiver.

See Also: - registerLockedObjectWithGlobalID:, - isObjectLockedWithGlobalID:, - forgetAllLocks, - forgetLocksForObjectsWithGlobalIDs:, - lockObjectWithGlobalID:editingContext:, - lockObject: (EOEditingContext)



localSnapshotForGlobalID:

- (NSDictionary *)localSnapshotForGlobalID:(EOGlobalID *)globalID

Returns the snapshot for the object identified by globalID, if there is one; else returns nil. Only searches locally (in the transaction scope), not in the EODatabase.

See Also: - recordSnapshot:forGlobalID:, - forgetSnapshotForGlobalID:, - recordSnapshots:, - snapshotForGlobalID:



localSnapshotForSourceGlobalID:relationshipName:

- (NSArray *)localSnapshotForSourceGlobalID:(EOGlobalID *)globalID relationshipName:(NSString *)name

Returns an array that is the snapshot for the objects at the destination of the to-many relationship named name, which is a property of the object identified by globalID. The returned array contains the globalIDs of the destination objects. If there is no snapshot, returns nil. Only searches locally (in the transaction scope), not in the EODatabase.

See Also: - recordSnapshot:forSourceGlobalID:relationshipName:, - snapshotForSourceGlobalID:relationshipName:



lock

- (void)lock

Used internally to protect access to the receiver in a multi-threaded environment. Do not confuse this with any methods which work with the database locking mechanism.

See Also: - unlock



lockObjectWithGlobalID:editingContext:

- (void)lockObjectWithGlobalID:(EOGlobalID *)globalID editingContext:(EOEditingContext *)anEditingContext

Overrides the inherited implementation to attempt to lock the database row corresponding to globalID in the underlying database server, on behalf of anEditingContext. If a transaction is not already open at the time of the lock request, the transaction is begun and is held open until either commitChanges or invalidateAllObjects is invoked. At that point all locks are released. Raises an NSInternalInconsistencyException if unable to obtain the lock.

See Also: - registerLockedObjectWithGlobalID:, - isObjectLockedWithGlobalID:, - forgetAllLocks, - forgetLocksForObjectsWithGlobalIDs:, - lockObject: (EOEditingContext)



missingObjectGlobalIDs

- (NSArray *)missingObjectGlobalIDs

Returns the globalIDs of any "missing" enterprise objects, or an empty array if no missing objects are known to the receiver. An object is "missing" when a fault fires and the corresponding row for the fault isn't found in the database.

To be notified when a missing object is discovered, implement the delegate method databaseContext:failedToFetchObject:globalID:.

If an application tries to save a missing object, an exception is raised.



objectsForSourceGlobalID:relationshipName:editingContext:

- (NSArray *)objectsForSourceGlobalID:(EOGlobalID *)globalID relationshipName:(NSString *)name editingContext:(EOEditingContext *)anEditingContext

Overrides the inherited implementation to service a to-many fault. The snapshot for the source object identified by globalID is located and the EORelationship named name is used to construct a qualifier from that snapshot. This qualifier is then used to fetch the requested objects into anEditingContext using the method objectsWithFetchSpecification:editingContext:.

objectsWithFetchSpecification:editingContext:

- (NSArray *)objectsWithFetchSpecification:(EOFetchSpecification *)fetchSpecification editingContext:(EOEditingContext *)anEditingContext

Overrides the inherited implementation to fetch objects from an external store into anEditingContext. The receiver obtains an available EODatabaseChannel and issues a fetch with fetchSpecification. If one of these objects is already present in memory, by default this method doesn't overwrite its values with the new values from the database (you can change this behavior; see the setRefreshesRefetchedObjects: method in the EOFetchSpecification class specification).

You can fine-tune the fetching behavior by adding hints to fetchSpecification's hints dictionary. For this purpose, Enterprise Objects Framework defines the following keys:


Constant Corresponding value in the hints dictionary
EOCustomQueryExpressionHintKey An NSString specifying raw SQL with which to perform the fetch. There is no way to pass down parameters with this hint.
EOStoredProcedureNameHintKey An NSString specifying a name for a stored procedure in the model that should be used rather than building the SQL statement. The stored procedure must query the exact same attributes in the same order as EOF would query if generating the SELECT expression dynamically. If this key is supplied, other aspects of the EOFetchSpecification such as isDeep, qualifier, and sortOrderings are ignored (in that sense, this key is more of a directive than a hint). There is no way to pass down parameters with this hint.

The class description contains additional information on using these hints. See "Using a Custom Query."

You can also use this method to implement "on-demand" locking by using a fetchSpecification that includes locking. For more discussion of this subject, see "Updating And Locking Strategies" in the class description.

Raises an exception if an error occurs; the error message indicates the nature of the problem.

See Also: - objectsWithFetchSpecification: (EOEditingContext)



ownsGlobalID:

- (BOOL)ownsGlobalID:(EOGlobalID *)globalID

Overrides the inherited implementation to return YES if the receiver is responsible for fetching and saving the object identified by globalID, NO otherwise. The receiver is determined to be responsible if globalID is a subclass of EOKeyGlobalID and globalID has an entity from one of the receiver's EODatabase's EOModels.

See Also: - handlesFetchSpecification:, - ownsObject:



ownsObject:

- (BOOL)ownsObject:(id)object

Overrides the inherited implementation to return YES if the receiver is responsible for fetching and saving object, NO otherwise. The receiver is determined to be responsible if the entity corresponding to object is in one of the receiver's EODatabase's EOModels.

See Also: - ownsGlobalID:, - handlesFetchSpecification:



performChanges

- (void)performChanges

Overrides the inherited implementation to construct EOAdaptorOperations from the EODatabaseOperations produced during recordChangesInEditingContext and recordUpdateForObject:changes:. Invokes the delegate method databaseContext:willOrderAdaptorOperationsFromDatabaseOperations: to give the delegate an opportunity to construct alternative EOAdaptorOperations from the EODatabaseOperations. Then invokes the delegate method databaseContext:willPerformAdaptorOperations:adaptorChannel: to let the delegate substitute its own array of EOAdaptorOperations. Gives the EOAdaptorOperations to an available EOAdaptorChannel for execution. If the save succeeds, updates the snapshots in the receiver to reflect the new state of the server. You should never need to invoke this method directly.

This method raises an exception if the adaptor is unable to perform the operations. The exception's userInfo dictionary contains these keys:


Key (NSString Constant) Value
EODatabaseContextKey The EODatabaseContext object that was trying to save to its underlying repository when the exception was raised.
EODatabaseOperationsKey The list of database operations the EODatabaseContext was trying to perform when the failure occurred.
EOFailedDatabaseOperationKey The database operation the EODatabaseContext failed to perform.

The userInfo dictionary may also contain some of the keys listed in the method description for the EOAdaptorChannel method performAdaptorOperation:. For more information, see the EOAdaptorChannel class specification.

See Also: - commitChanges, - rollbackChanges



prepareForSaveWithCoordinator:editingContext:

- (void)prepareForSaveWithCoordinator:(EOObjectStoreCoordinator *)coordinator editingContext:(EOEditingContext *)anEditingContext

Overrides the inherited implementation to do whatever is necessary to prepare to save changes. If needed, generates primary keys for any new objects in anEditingContext that are owned by the receiver. This method is invoked before the object graph is analyzed and foreign key assignments are performed. You should never need to invoke this method directly.

recordChangesInEditingContext

- (void)recordChangesInEditingContext

Overrides the inherited implementation to construct a list of EODatabaseOperations for all changes to objects in the EOEditingContext that are owned by the receiver. Forwards any relationship changes discovered but not owned by the receiver to the EOObjectStoreCoordinator. This method is typically invoked in the course of an EOObjectStoreCoordinator saving changes through its saveChangesInEditingContext: method. It's invoked after prepareForSaveWithCoordinator:editingContext: and before ownsGlobalID:. You should never need to invoke this method directly.

recordSnapshot:forGlobalID:

- (void)recordSnapshot:(NSDictionary *)snapshot forGlobalID:(EOGlobalID *)globalID

Records aSnapshot under globalID. This method only records snapshots locally (in the transaction scope). If you want to record snapshots globally, use the corresponding EODatabase method.

See Also: - forgetSnapshotForGlobalID:, - localSnapshotForGlobalID:, - recordSnapshots:, - snapshotForGlobalID:



recordSnapshot:forSourceGlobalID:relationshipName:

- (void)recordSnapshot:(NSArray *)globalIDs forSourceGlobalID:(EOGlobalID *)globalID relationshipName:(NSString *)name

For the object identified by globalID, records an NSArray of globalIDs for the to-many relationship named name. These globalIDs identify the objects at the destination of the relationship. This method only records snapshots locally (in the transaction scope). If you want to record snapshots globally, use the corresponding EODatabase method.

See Also: - snapshotForSourceGlobalID:relationshipName:, - localSnapshotForSourceGlobalID:relationshipName:, - recordToManySnapshots:



recordSnapshots:

- (void)recordSnapshots:(NSDictionary *)snapshots

Records the objects in snapshots, a dictionary of snapshots. The snapshots argument's keys are GlobalIDs and its values are the corresponding snapshots represented as NSDictionaries. This method only records snapshots locally (in the transaction scope). If you want to record snapshots globally, use the corresponding EODatabase method.

See Also: - recordSnapshot:forGlobalID:, - localSnapshotForGlobalID:, - forgetSnapshotForGlobalID:, - snapshotForGlobalID:



recordToManySnapshots:

- (void)recordToManySnapshots:(NSDictionary *)snapshots

Records the objects in snapshots. snapshots should be an NSDictionary of NSDictionaries, in which the top-level dictionary has as its key the globaID of the enterprise object for which to-many relationships are being recorded. The key's value is a dictionary whose keys are the names of the Enterprise Object's to-many relationships. Each of these keys in turn has as its value an array of globalIDs that identify the objects at the destination of the relationship.

This method only records snapshots locally (in the transaction scope). If you want to record snapshots globally, use the corresponding EODatabase method.

See Also: - recordSnapshot:forSourceGlobalID:relationshipName:, - snapshotForSourceGlobalID:relationshipName:, - localSnapshotForSourceGlobalID:relationshipName:



recordUpdateForObject:changes:

- (void)recordUpdateForObject:(id)object changes:(NSDictionary *)changes

Overrides the inherited implementation to communicate to the receiver that changes from another EOCooperatingObjectStore (through the EOObjectStoreCoordinator) need to be made to an object in the receiver. For example, an insert of an object in a relationship property might require changing a foreign key property in an object owned by another cooperating store. This method can be invoked any time after prepareForSaveWithCoordinator:editingContext: and before ownsGlobalID:.

refaultObject:withGlobalID:editingContext:

- (void)refaultObject:(id)anObject withGlobalID:(EOGlobalID *)globalID editingContext:(EOEditingContext *)anEditingContext

Overrides the inherited implementation to refault the enterprise object identified by globalID in anEditingContext. Newly-inserted objects should not be refaulted, since they can't be refetched from the external store. If you attempt to do this, an exception will be raised. Don't refault to-many relationship arrays, just recreate them.

This method should be used with caution since refaulting an object doesn't remove the object snapshot from the undo stack, after which the object snapshot may not refer to the proper object.



registerChannel:

- (void)registerChannel:(EODatabaseChannel *)channel

Registers channel, which means that it adds it to the pool of available channels used to service fetch and fault requests. Registered channels are retained by the receiver. You use this method if you need to perform more than one fetch simultaneously.

See Also: - availableChannel, - registeredChannels, - unregisterChannel:



registeredChannels

- (NSArray *)registeredChannels

Returns all of the EODatabaseChannels that have been registered for use with the receiver.

See Also: - registerChannel:, - availableChannel, - unregisterChannel:



registerLockedObjectWithGlobalID:

- (void)registerLockedObjectWithGlobalID:(EOGlobalID *)globalID

Registers as a locked object the enterprise object identified by globalID. This method is used internally to keep track of objects corresponding to rows that are locked in the database.

See Also: - forgetAllLocks, - isObjectLockedWithGlobalID:, - forgetLocksForObjectsWithGlobalIDs:, - lockObjectWithGlobalID:editingContext:, - lockObject: (EOEditingContext)



rollbackChanges

- (void)rollbackChanges

Overrides the inherited implementation to instruct the adaptor to roll back the transaction. Rolls back any changed snapshots, and releases all locks.

See Also: - ownsGlobalID:, - commitChanges



saveChangesInEditingContext:

- (void)saveChangesInEditingContext:(EOEditingContext *)context

Overrides the inherited implementation to save the changes made in context. This message is sent by an EOEditingContext to its EOObjectStore to commit changes. Normally an editing context doesn't send this message to an EODatabaseContext, but to an EOObjectStoreCoordinator. Raises an exception if an error occurs; the error message indicates the nature of the problem.

setDelegate:

- (void)setDelegate:(id)delegate

Sets the receiver's delegate to delegate, and propagates the delegate to all of the receiver's EODatabaseChannels. EODatabaseChannels share the delegate of their EODatabaseContext.

See Also: - delegate



setUpdateStrategy:

- (void)setUpdateStrategy:(EOUpdateStrategy)strategy

Sets the update strategy used by the EODatabaseContext to strategy. See "Updating And Locking Strategies" for information on the update strategies:

Raises an NSInvalidArgumentException if the receiver has any transactions in progress or if you try to set strategy to EOUpdateWithPessimisticLocking and the receiver's EODatabase already has snapshots.

See Also: - updateStrategy



snapshotForGlobalID:

- (NSDictionary *)snapshotForGlobalID:(EOGlobalID *)globalID

Equivalent to invoking snapshotForGlobalID:after: with EODistantPastTimeInterval as the time interval, this method returns the snapshot associated with globalID.

See Also: - recordSnapshot:forGlobalID:, - localSnapshotForGlobalID:, - forgetSnapshotForGlobalID:, - recordSnapshots:



snapshotForGlobalID:after:

- (NSDictionary *)snapshotForGlobalID:(EOGlobalID *)globalId after:(NSTimeInterval)timestamp

Returns the snapshot associated with globalID. Returns nil if there isn't a snapshot for the globalID or if the corresponding timestamp is less than timestamp. Searches first locally (in the transaction scope) and then in the EODatabase.

snapshotForSourceGlobalID:relationshipName:

- (NSArray *)snapshotForSourceGlobalID:(EOGlobalID *)globalID relationshipName:(NSString *)name

Equivalent to invoking snapshotForSourceGlobalID:relationshipName: with EODistantPastTimeInterval as the time interval, this method returns the to-many snapshot for globalId and name.

See Also: - recordSnapshot:forSourceGlobalID:relationshipName:, - localSnapshotForSourceGlobalID:relationshipName:, - recordToManySnapshots:



snapshotForSourceGlobalID:relationshipName:after:

- (NSArray *)snapshotForSourceGlobalID:(EOGlobalID *)globalId relationshipName:(NSString *)name after:(NSTimeInterval)timestamp

Returns the to-many snapshot for globalId and name. A to-many snapshot is an array of globalIDs. These globalIDs identify the objects at the destination of the to-many relationship named name, which is a property of the object identified by globalID. Returns nil if there isn't a to-many snapshot for globalId or if the timestamp is less than timestamp. Searches first locally (in the transaction scope) and then in the EODatabase.

unlock

- (void)unlock

Used internally to release the lock that protects access to the receiver in a multi-threaded environment.

See Also: - lock



unregisterChannel:

- (void)unregisterChannel:(EODatabaseChannel *)channel

Unregisters the EODatabaseChannel channel, which means that it removes it from the pool of available channels used for database communication (for example, to service fetch and fault requests).

See Also: - registerChannel:, - registeredChannels, - availableChannel



updateStrategy

- (EOUpdateStrategy)updateStrategy

Returns the update strategy used by the receiver, one of:

The default strategy is EOUpdateWithOptimisticLocking.

See Also: - setUpdateStrategy:



valuesForKeys:object:

- (NSDictionary *)valuesForKeys:(NSArray *)keys object:(id)object

Overrides the inherited implementation to return values for the specified keys from the snapshot of object. The returned values are used primarily by another EODatabaseContext to extract foreign key properties for objects owned by the receiver.


Notifications


EODatabaseChannelNeededNotification

This notification is broadcast whenever an EODatabaseContext is asked to perform an object store operation and it doesn't have an available EODatabaseChannel. Subscribers can create a new channel and add it to the EODatabaseContext at this time.
Notification Object The EODatabaseContext.
userInfo Dictionary None.



Table of Contents