Working with Direct Collection Mappings

Direct collection mappings store collections of Java objects that are not 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 5-18 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 5-18 Direct Collection Mappings

This figure shows a direct collection mapping.


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" for details.

Maps are not supported for direct collection because there is no key value.


Related Topics

About TopLink Mapping Types
Working with Relationship Mappings

Creating Direct Collection Mappings for Java Objects

 

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