Documentation Archive Developer
Search
PATH  WebObjects 4.0 Documentation > EOAccess Reference



EODatabase

Inherits From:
NSObject

Conforms To: NSObject (NSObject)

Declared in: EOAccess/EODatabase.h


Class Description

An EODatabase object represents a single database server. It contains an EOAdaptor which is capable of communicating with the server, a list of EOModels that describe the server's schema, a list of EODatabaseContexts that are connected to the server, and a set of snapshots representing the state of all objects stored in the server.

For more information, see "More about EODatabase".


Method Types

Creating instances - initWithModel:
- initWithAdaptor:
Adding and removing models
- addModel:
- addModelIfCompatible:
- removeModel:
- models
Accessing entities
- entityForObject:
- entityNamed:
Recording snapshots
- recordSnapshot:forGlobalID:
- forgetSnapshotForGlobalID:
- forgetSnapshotsForGlobalIDs:
- recordSnapshots:
- forgetAllSnapshots
- snapshotForGlobalID:
- snapshots
- recordSnapshot:forSourceGlobalID:relationshipName:
- recordToManySnapshots:
- snapshotForSourceGlobalID:relationshipName:
Registering database contexts
- registerContext:
- unregisterContext:
- registeredContexts
Accessing the adaptor
- adaptor
Managing the result cache
- invalidateResultCache
- invalidateResultCacheForEntityNamed:
- resultCacheForEntityNamed:
- setResultCache:forEntityNamed:

Instance Methods


adaptor

- (EOAdaptor *)adaptor

Returns the EOAdaptor used by the receiver for communication with the database server. Your application can interact directly with the EOAdaptor, but should avoid altering its state (for example, by starting a transaction with one of its adaptor contexts).


addModel:

- (void)addModel:(EOModel *)aModel

Adds aModel to the receiver's list of EOModels. This allows EODatabases to load entities and their properties only as they're needed, by dividing them among separate EOModels. aModel must use the same EOAdaptor as the receiver and use the same connection dictionary as the receiver's other EOModels.

See also: - addModelIfCompatible:, - models, - removeModel:


addModelIfCompatible:

- (BOOL)addModelIfCompatible:(EOModel *)aModel

Adds aModel to the receiver's list of EOModels, checking first to see whether it's compatible with those other EOModels. Returns YES if aModel is already in the list or if it's successfully added. Returns NO if aModel's adaptor name differs from that of the receivers or if the receiver's adaptor returns NO to a canServiceModel: message.

See also: - addModel:, - models, - removeModel:


entityForObject:

- (EOEntity *)entityForObject:(id)anObject

Returns the EOEntity from one of the receiver's Models that's mapped to anObject, or nil if there is no such EOEntity. This method works by sending entityForObject: messages to each of the receiver's EOModels and returning the first one found.

See also: - entityNamed:


entityNamed:

- (EOEntity *)entityNamed:(NSString *)entityName

Returns the EOEntity from one of the receiver's Models that's named entityName, or nil if there is no such EOEntity. This method works by sending entityNamed: messages to each of the receiver's EOModels and returning the first one found.

See also: - entityForObject:


forgetAllSnapshots

- (void)forgetAllSnapshots

Clears all of the receiver's snapshots and posts an EOObjectsChangedInStoreNotification (defined in the EOControl framework's EOObjectStore class) describing the invalidated object. For a description of snapshots and their role in an application, see the class description.

See also: - forgetSnapshotForGlobalID:, - forgetSnapshotsForGlobalIDs:, - recordSnapshot: forGlobalID:, - recordSnapshots:, - recordSnapshot:forSourceGlobalID:relationshipName: , - recordToManySnapshots:


forgetSnapshotForGlobalID:

- (void)forgetSnapshotForGlobalID:(EOGlobalID *)globalID

Clears the snapshot made for the enterprise object identified by globalID and posts an EOObjectsChangedInStoreNotification (defined in the EOControl framework's EOObjectStore class) describing the invalidated object. For a description of snapshots and their role in an application, see the class description.

See also: - forgetSnapshotsForGlobalIDs:, - forgetAllSnapshots, - recordSnapshot:forGlobalID:


forgetSnapshotsForGlobalIDs:

- (void)forgetSnapshotsForGlobalIDs:(NSArray *)globalIDs

Clears the snapshots made for the enterprise objects identified by each of the EOGlobalIDs in globalIDs and posts an EOObjectsChangedInStoreNotification (defined in the EOControl framework's EOObjectStore class) describing the invalidated objects. For a description of snapshots and their role in an application, see the class description.

See also: - forgetSnapshotForGlobalID:, - forgetAllSnapshots, - recordSnapshots:


initWithAdaptor:

- initWithAdaptor:(EOAdaptor *)anAdaptor

The designated initializer, this method initializes a newly allocated EODatabase with anAdaptor as its adaptor and returns self.

Typically, you don't need to programmatically create EODatabase objects. Rather, they are created automatically by the control layer. See the class description for more information. If you do need to create an EODatabase programmatically, you should never associate more than one EODatabase with a given EOAdaptor. In general, use initWithModel:, which automatically selects the adaptor.


initWithModel:

- initWithModel:(EOModel *)aModel

Initializes a newly allocated EODatabase by creating an instance of EOAdaptor named in aModel and invoking initWithAdaptor:. Returns self. Typically, you don't need to programmatically create EODatabase objects. Rather, they are created automatically by the control layer. See the class description for more information.

See also: + adaptorWithModel: (EOAdaptor), - adaptorName (EOModel)


invalidateResultCache

- (void)invalidateResultCache

Invalidates the receiver's result cache. See the class description for more discussion of this topic.

See also: - invalidateResultCacheForEntityNamed:, - resultCacheForEntityNamed:


invalidateResultCacheForEntityNamed:

- (void)invalidateResultCacheForEntityNamed:(NSString *)entityName

Invalidates the result cache containing an array of globalIDs for the objects associated with the entity entityName. See the class description for more discussion of this topic.

See also: - invalidateResultCache, - resultCacheForEntityNamed:


models

- (NSArray *)models

Returns the receiver's EOModels.

See also: - initWithModel:, - addModel:, - addModelIfCompatible:, - removeModel:


recordSnapshot:forGlobalID:

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

Records aSnapshot under globalID. For a description of snapshots and their role in an application, see the class description.

See also: - globalIDForRow: (EOEntity), - recordSnapshots:, - forgetSnapshotForGlobalID:


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. For a description of snapshots and their role in an application, see the class description.

See also: - recordSnapshot:forGlobalID:, - recordSnapshots:, - recordSnapshot:forGlobalID:, - snapshotForSourceGlobalID:relationshipName:


recordSnapshots:

- (void)recordSnapshots:(NSDictionary *)snapshots

Records the snapshots in snapshots. snapshots is a dictionary whose keys are EOGlobalIDs and whose values are the snapshots for those global IDs. For a description of snapshots and their role in an application, see the class description.

See also: - recordSnapshot:forGlobalID:, - forgetSnapshotsForGlobalIDs:


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. For a description of snapshots and their role in an application, see the class description.

See also: - recordSnapshot:forSourceGlobalID:relationshipName:, - recordSnapshot:forGlobalID:, - snapshotForSourceGlobalID:relationshipName:


registerContext:

- (void)registerContext:(EODatabaseContext *)aContext

Records aContext as one of the receiver's EODatabaseContexts, without retaining it. . aContext must have been created with the receiver using EODatabaseContext's initWithDatabase: method, which invokes this method automatically. You should never need to invoke this method directly.

See also: - unregisterContext:, - registeredContexts


registeredContexts

- (NSArray *)registeredContexts

Returns all the EODatabaseContexts that have been registered with the receiver, generally all the database contexts that were created with the receiver as their EODatabase object.

See also: - registerContext:, - unregisterContext:


removeModel:

- (void)removeModel:(EOModel *)aModel

Removes aModel from the receiver's list of EOModels. Raises an exception if aModel isn't one of the receiver's models.

See also: - addModel:, - addModelIfCompatible:, - models


resultCacheForEntityNamed:

- (NSArray *)resultCacheForEntityNamed:(NSString *)entityName

Returns an array containing the globalIDs of the objects associated with entityName. See the class description for more discussion of this topic.

See also: - invalidateResultCache, - invalidateResultCacheForEntityNamed:


setResultCache:forEntityNamed:

- (void)setResultCache:(NSArray *)cache forEntityNamed:(NSString *)entityName

Updates the receiver's cache for entityName with cache, an array of EOGlobalID objects, for all the enterprise objects associated with the EOEntity named entityName. This method is invoked automatically, and you should never need to invoke it directly. For more information on this topic, see the class description.

See also: - invalidateResultCache, - invalidateResultCacheForEntityNamed:, - resultCacheForEntityNamed:


snapshotForGlobalID:

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

Returns the snapshot associated with globalID if there is one; otherwise returns nil. For a description of snapshots and their role in an application, see the class description.

See also: - recordSnapshot:forGlobalID:, - forgetSnapshotForGlobalID:


snapshotForSourceGlobalID:relationshipName:

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

Returns a snapshot that consists of 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. If there is no snapshot, returns nil. For a description of snapshots and their role in an application, see the class description.


snapshots

- (NSDictionary *)snapshots

Returns all of the receiver's snapshots, stored in a dictionary under their EOGlobalIDs.

See also: - recordSnapshot:forSourceGlobalID:relationshipName:, - recordToManySnapshots:


unregisterContext:

- (void)unregisterContext:(EODatabaseContext *)aContext

Removes aContext as one of the receiver's EODatabaseContexts, without releasing it. An EODatabaseContext automatically invokes this method when deallocated; you should never need to invoke it directly.

See also: - registerContext:, - registeredContexts






Copyright © 1998, Apple Computer, Inc. All rights reserved.