The following sequence of events occurs when an object is fetched from the database:
A database row is fetched as raw binary data.
The values retrieved from that row are converted from their database-specific types to instances of standard value classes. A sample mapping of this conversion appears in “Table 6-1.” An application’s EOModel specifies the mapping from external data types (database type) to internal data types (Java value type).
Database type | Java value type |
|---|---|
| String |
| NSTimestamp |
| NSData |
| Integer |
null values in the database are mapped to an instance of NSKeyValueCoding.NullValue.
Once the data has been converted to objects, these objects are put in an NSDictionary. The elements of the dictionary correspond to columns in the database table: Their names are the names of the attributes they map to in the EOModel and their values are the values retrieved from the database.
The dictionary provides a snapshot of the database row and is eventually used to initialize an enterprise object. This snapshot also participates in optimistic locking.
The dictionary contains an entry for all of a row’s columns, but an enterprise object initialized from the dictionary contains only the attributes that are defined as class properties or client-side class properties in the entity’s EOModel.
A new enterprise object is instantiated by an EOEntityClassDescription object.
The enterprise object is initialized from a row snapshot. Only objects that are class properties or client-side class properties are included. Faults are created for any references to relationships defined in the EOModel.
“Figure 6-2” illustrates the relationship between database rows, database context snapshots, and enterprise object instances.
Last updated: 2007-07-11