Skip Headers
Oracle® Application Server TopLink Mapping Workbench User's Guide
10g Release 2 (10.1.2)
Part No. B15900-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

Working with Direct Collection Mappings

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.

Figure 6-20 Direct Collection Mappings

Description of dcmapfig.gif follows
Description of the illustration dcmapfig.gif

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.

Creating Direct Collection Mappings

Use this procedure to create a direct collection mapping.

To create a direct collection mapping:

  1. Select the attribute to be mapped from the Navigator pane.

  2. Direct Collection Mapping button.
    Description of the illustration dcmapbtn.gif

    Click the Direct Collection Mapping button on the mapping toolbar.

Figure 6-21 Direct Collection Mapping General Properties

Description of dcmapgen.gif follows
Description of the illustration dcmapgen.gif

  1. Use the Target Table and Direct Field drop-down lists to specify the appropriate information.

  2. Enter any other required information on the General tab (see "Working with Common Mapping Properties" on page 4-70).

  3. Click the Collection Options tab to specify collection information for this mapping. See "Specifying Collection Properties" on page 4-73 for more information.

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

Description of dctable.gif follows
Description of the illustration dctable.gif

  1. Choose the appropriate reference that relates the target table to the tables associated with the source descriptor.