Using Query Keys in Interface Descriptors

Interface descriptors are defined only with query keys that are shared among their implementors. In the descriptor for the interface, only the name of the query key is specified.

In each implementor descriptor, the key must be defined, and with appropriate field, from one of the implementor descriptor's tables.

Doing this ensures that a single query key can be used to specify foreign key information from a descriptor that contains a mapping to the interface, even if the field names differ.

Consider an Employee that contains a contact, of type Contact. Contact is an interface with two implementors: Phone and EmailAddress. Each class has two attributes. The following figure illustrates the generated keys:

Figure 4-29 Auto-generated Query Keys for Phone and Email

This figure shows auto-generated keys for the Phone and Email classes.


Note: Both classes have an attribute, id, that is directly mapped to fields that have different names. However, a query key is generated for this attribute. For the Contact interface descriptor, indicate that the id query key must be defined for each of the implementors, as Figure 4-30 illustrates.

Figure 4-30 Contact interface Descriptor with Common Query Key id

This figure shows the Implementors tab with descriptors that share a common query key.


Note: If either of the implementor classes did not have the id query key defined, that descriptor would be flagged as deficient.

Now that a descriptor with a commonly shared query key has been defined for Contact, you can use it as the reference class for a variable one-to-one mapping. For example, you can now create a one-to-one mapping for the contact attribute of Employee. When you edit the foreign key field information for the mapping, you must match the Employee descriptor's tables to query keys from the Contact interface descriptor.

See "Working with Interfaces" and "Working with Java Object Relationship Mappings" for more information.


Related Topics

About TopLink Descriptors

Automatically Generating Query Keys
Using Relationship Query Keys

Working with Query Keys
Specifying Query Keys
Working with Descriptors

 

Copyright © 1997, 2004, Oracle. All rights reserved.