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 Array Mappings

In an object-relational data-model, structures can contain arrays (collections of other data types). These arrays can contain primitive data types or collections of other structures. OracleAS TopLink stores the arrays with their parent structure in the same table.

All elements in the array must be the same data type. The number of elements in an array controls the size of the array. An Oracle database allows arrays of variable sizes (called Varrays).

Oracle8i offers two collection types:

OracleAS TopLink supports arrays of primitive data through the ArrayMapping class. This is similar to DirectCollectionMapping – it represents a collection of primitives in Java. However, the ArrayMapping class does not require an additional table to store the values in the collection.

OracleAS TopLink supports arrays of aggregate structures through the ObjectArrayMaping class.

OracleAS TopLink supports nested tables through the NestedTableMapping class.

Implementing Array Mappings in Java

Array mappings are instances of the ArrayMapping class. You must associate this mapping to an attribute in the parent class. OracleAS TopLink requires the following elements for an array mapping:

  • Attribute being mapped – Set by sending the setAttributeName( ) message.

  • Field being mapped – Set by sending the setFieldName( ) message.

  • Name of the array – Set by sending the setStructureName( ) message.

Table 7-1 summarizes all array mapping properties:

Example 7-1 Array Mapping

The following code example illustrates creating an array mapping for the Employee source class and registering it with the descriptor

// Create a new mapping and register it with the source descriptor.
ArrayMapping arrayMapping = new ArrayMapping();
arrayMapping.setAttributeName("responsibilities");
arrayMapping.setStructureName("Responsibilities_t");
arrayMapping.setFieldName("RESPONSIBILITIES");
descriptor.addMapping(arrayMapping);

Reference

The following table summarizes all array mapping properties. In the Method Names column, arguments are bold, methods are not.

Table 7-1 Properties for ArrayMapping methods

Property Default Method Names

* Required property




Attribute to be mapped * not applicable setAttributeName(String name)
Set parent class * not applicable setReferenceClass(Class referenceClass)
User-defined data type * not applicable setStructureName(String Structurename)
Field to be mapped * not applicable setFieldName(String fieldName)
Method access direct access setGetMethodName(String name)

setSetMethodName(String name)

Read only read / write readWrite()

readOnly()

setIsReadOnly(boolean readOnly)