Documentation Archive Developer
Search
PATH  Documentation > WebObjects 4.5 > EOF Tools and Techniques

Table of Contents Previous Section

Specifying an Enterprise Object Class

Specifying an enterprise object class for an entity applies the mapping defined in your model to your custom class, thereby enabling objects of the class to be created from database rows.

To specify the enterprise object class for an entity:

  1. Make sure that each of the properties you want to include in your enterprise object class has a Class Property icon set for it in the Inspector.

  2. If the entity does not already have a primary key specified, add a Primary Key icon for the property or properties that constitute the entity's primary key.

    Remember that the primary key or keys you set for your enterprise object class must mirror the primary key or keys defined for the corresponding table in the database.

What you do after this point depends on how you plan to implement your enterprise object class. In all cases, an enterprise object class must conform to the EOKeyValueCoding interface (or informal protocol in Objective-C), which specifies methods for accessing values by name, or key ("keys" in this context relates to key-value pairs, not to primary keys). But this can be accomplished very differently, depending on the approach you use.

You can use either of the following approaches, depending on the needs of your application:

You can also use EOModeler to generate source code for your class; the resulting source files include definitions of instance variables and accessor methods that can be used by key-value coding. See Generating Source Files.

For more information on key-value coding and implementing enterprise object classes, see the chapter Designing Enterprise Objects in the book Enterprise Objects Framework Developer's Guide.

Table of Contents Next Section