Oracle® Application Server TopLink Mapping Workbench User's Guide
10g Release 2 (10.1.2) Part No. B15900-01 |
|
Previous |
Next |
Direct collection mappings store collections of Java objects that are not OracleAS TopLink-enabled. The object type stored in the direct collection is typically a Java type, such as String
.
It is also possible to use direct collection mappings to map a collection of non-String
objects. For example, it is possible to have an attribute that contains a collection of Integer
or Date
instances. The instances stored in the collection can be any type supported by the database and has a corresponding wrapper class in Java.
Support for primitive data types such as int
is not provided because Java vectors hold only objects.
Figure 6-20 illustrates how a direct collection is stored in a separate table with two fields. The first field is the reference key field, which contains a reference to the primary key of the instance owning the collection. The second field contains an object in the collection and is called the direct field. There is one record in the table for each object in the collection.
Maps are not supported for direct collection because there is no key value.
Note: The responsibilities attribute is of type Vector. When using JDK 1.2, it is possible to use a Collection interface (or any class that implements the Collection interface) for declaring the collection attribute. See "Working with a Container Policy" on page 6-4 for details. |
Use this procedure to create a direct collection mapping.
To create a direct collection mapping:
Select the attribute to be mapped from the Navigator pane.
Description of the illustration dcmapbtn.gif
Click the Direct Collection Mapping button on the mapping toolbar.
Figure 6-21 Direct Collection Mapping General Properties
Use the Target Table and Direct Field drop-down lists to specify the appropriate information.
Enter any other required information on the General tab (see "Working with Common Mapping Properties" on page 4-70).
Click the Collection Options tab to specify collection information for this mapping. See "Specifying Collection Properties" on page 4-73 for more information.
Click the Table Reference tab to specify foreign key information for this mapping. See "Creating Table References" on page 3-6 for more information.
Figure 6-22 Direct Collection Mapping Table Reference Properties
Choose the appropriate reference that relates the target table to the tables associated with the source descriptor.