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

Table of Contents

EOGenericRecord


Inherits from:
NSObject
Conforms to:
NSCoding
NSObject (NSObject)
Declared in:
EOControl/EOGenericRecord.h




Class Description


EOGenericRecord is a generic enterprise object class that can be used in place of custom classes when you don't need custom behavior. It implements the EOEnterpriseObject interface to provide the basic enterprise object behavior. An EOGenericRecord object has an EOClassDescription that provides metadata about the generic record, including the name of the entity that the generic record represents and the names of the record's attributes and relationships. A generic record stores its properties in a dictionary using its attribute and relationship names as keys.

In the typical case of applications that access a relational database, the access layer's modeling objects are an important part of how generic records map to database rows: If an EOModel doesn't have a custom enterprise object class defined for a particular entity, an EODatabaseChannel using that model creates EOGenericRecords when fetching objects for that entity from the database server. During this process, the EODatabaseChannel also sets each generic record's class description to an EOEntityClassDescription, providing the link to the record's associated modeling objects. (EOModel, EODatabaseChannel, and EOEntityClassDescription are defined in EOAccess.)


Creating an Instance of EOGenericRecord

The best way to create an instance of EOGenericRecord is using the EOClassDescription method createInstanceWithEditingContext:globalID:zone: as follows:

id newEO;
NSString *entityName;             // Assume this exists.

newEO = [[EOClassDescription classDescriptionForEntityName:entityName]
    createInstanceWithEditingContext:nil
    globalID:nil
     zone:nil];

createInstanceWithEditingContext:globalID:zone: is preferable to EOGenericRecord's init... method because the same code works if you later use a custom enterprise object class instead of EOGenericRecord. You can get an EOClassDescription for an entity name as shown above. Alternatively, you can get an EOClassDescription for a destination key of an existing enterprise object as follows:

id newEO;
id existingEO;              // Assume this exists.
NSString *relationshipName; // Assume this exists.
EOClassDescription *description = [existingEO classDescription];

newEO = [[description classDescriptionForDestinationKey:relationshipName]
    createInstanceWithEditingContext:editingContext
    lobalID:nil
    zone:nil];

The technique in this example is useful for inserting a new destination object into an existing enterprise object-for creating a new Movie object to add to a Studio's array of Movies, for example.




Class Methods



useDeferredFaultCreation

+ (BOOL)useDeferredFaultCreation

Returns YES, specifying that EOGenericRecords use deferred faulting (which is more efficient than the regular faulting mechanism).


Instance Methods



init

- (id)init

Don't invoke this method. It doesn't work to create instances of EOGenericRecord or its subclasses. Subclasses of EOGenericRecord shouldn't implement this method. Rather, they should implement initWithEditingContext:classDescription:globalID:.

initWithEditingContext:classDescription:globalID:

- (id)initWithEditingContext:(EOEditingContext *)anEditingContext classDescription:(EOClassDescription *)aClassDescription globalID:(EOGlobalID *)globalID

The designated initializer, this method initializes a newly allocated EOGenericRecord to get its metadata from aClassDescription. You should pass nil for anEditingContext and globalID, because the arguments are optional: EOGenericRecord's implementation does nothing with them. Raises an NSInternalInconsistencyException if aClassDescription is nil. Returns self.

You shouldn't use this method to create new EOGenericRecords. Rather, use EOClassDescription's createInstanceWithEditingContext:globalID:zone: method. See the class description for more information.



storedValueForKey:

- (id)storedValueForKey:(NSString *)key

Overrides the default implementation to simply invoke valueForKey:.

See Also: storedValueForKey: ( EOKeyValueCoding)



takeStoredValue:forKey:

- (void)takeStoredValue:(id)value forKey:(NSString *)key

Overrides the default implementation to simply invoke takeValue:forKey:.

See Also: takeStoredValue:forKey: ( EOKeyValueCoding)



takeValue:forKey:

- (void)takeValue:(id)value forKey:(NSString *)key

Invokes the receiver's willChange method, and sets the value for the property identified by key to value. If value is nil, this method removes the receiver's dictionary entry for key. (EOGenericRecord overrides the default implementation.) If key is not one of the receiver's attribute or relationship names, EOGenericRecord's implementation does not invoke handleTakeValue:forUnboundKey:. Instead, EOGenericRecord's implementation does nothing.

valueForKey:

- (id)valueForKey:(NSString *)key

Returns the value for the property identified by key. (EOGenericRecord overrides the default implementation.) If key is not one of the receiver's attribute or relationship names, EOGenericRecord's implementation does not invoke handleQueryWithUnboundKey:. Instead, EOGenericRecord's implementation simply returns nil.


Table of Contents