Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page > Hide TOC

Enterprise Object Initialization

The following sequence of events occurs when an object is fetched from the database:

  1. A database row is fetched as raw binary data.

  2. 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).

    Table 5-1  Database type to Java value type mapping

    Database type

    Java value type

    char

    String

    date

    NSTimestamp

    blob

    NSData

    int

    Integer

    null values in the database are mapped to an instance of NSKeyValueCoding.NullValue.

  3. 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.

  4. A new enterprise object is instantiated by an EOEntityClassDescription object.

  5. 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.


Figure 5-2  Relationship between rows, snapshots, and enterprise objects

Relationship between rows, snapshots, and enterprise objects



< Previous PageNext Page > Hide TOC


Last updated: 2007-07-11




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice