PATH  Documentation > WebObjects 4.5 > EOF Tools and Techniques

Table of Contents Previous Section

Using the Entity Inspector

You use the Entity Inspector to set an entity's characteristics and specify a mapping between the entity and an enterprise object class. You can also accomplish the same tasks using the table mode of the Model Editor, but this section focuses on the Entity Inspector.

To inspect an entity, select the entity in the Model Editor and open the inspector (either with the button on the tool bar or by choosing Tools Inspector).

Figure 35 shows the Entity Inspector for the Movie entity.

Figure 35. The Entity Inspector

Name and Table Name

The Name field lists the name your application uses for the entity. The Table Name field contains the name of the root table in the database. You can change the internal name (that is, the name as it appears in the application), but you shouldn't change the database table name unless you have also changed the name in your database server.

Class

The Class field initially contains the text "EOGenericRecord". This is because the default enterprise object class is an EOGenericRecord. To specify a custom class, type the name of the class in this field. For more information on creating custom classes, see Specifying an Enterprise Object Class.

Properties

The Properties area lets you specify the properties you want to include in your enterprise object class and set characteristics for them.

There are three columns in this area. Each column displays the status of a particular setting: Primary Key, Used For Locking, and Class Property. Icons are used to indicate that a setting is enabled for a particular property; the dash icon indicates that a setting is not applicable to a property. You add and delete icons by clicking the appropriate column next to the property.

The Primary Key column is used to declare whether a property is, or is part of, the primary key for the enterprise object class. To specify a compound primary key, you simply add a Primary Key icon to the column for each property you want to include in the primary key.

Specifying a primary key for your enterprise object class is mandatory; the primary key is the means by which an enterprise object is uniquely identified within your application and mapped to the appropriate database row.

Note: Enterprise Objects Framework doesn't support modifiable primary key values. You shouldn't design your application so that users can change a primary key's value.

The Class Property column is used to indicate properties that meet both of these criteria: You want to include them in your class definition, and they can be fetched from the database. By default, the Entity Inspector sets all of an entity's properties as belonging to your class. You can remove a property by clicking its Class Property icon. If you define an attribute that doesn't exist in the database but is used by your application (such as a computed value), you should remove its Class Property icon. Note that generated source files won't include instance variable declarations for these attributes-you'll have to type those in by hand (this is a rare case). You also should not include primary and foreign keys as class properties unless you need to display their values in the user interface. If you don't remove the Class Property icon for an attribute that has no corresponding database value, it will result in a server error when your application attempts to fetch the property from the database.

The Used For Locking column indicates whether an attribute should be checked for changes before an update is allowed. This setting applies when you're using Enterprise Object Framework's default update strategy, optimistic locking. Under optimistic locking, the state of a row is saved as a snapshot when you fetch it from the database. When you perform an update, the snapshot is checked against the row to make sure the row hasn't changed. If you set Used For Locking for an attribute whose data is a BLOB type, it can have an adverse effect on system performance. By default, the Entity Inspector sets all of an entity's attributes to be used for locking.

In Figure 35, note that:

Table of Contents Next Section