Skip Headers

# Direct Collection Mapping

Previous

Next

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 `Vector`s hold only objects.

Figure: Direct Collection Mappings 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.

Direct Collection Mappings

Description of "Direct Collection Mappings "

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

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

You can use a direct collection mapping with any of the following `Converter` instances:

- see "Object Type Converter"

- see "Serialized Object Converter"

- see "Type Conversion Converter"

You can use a direct collection mapping with a change policy (see "Configuring Change Policy").

See "Configuring a Relational Direct Collection Mapping" for more information.