Oracle® Application Server TopLink Mapping Workbench User's Guide
10g Release 2 (10.1.2) Part No. B15900-01 |
|
Previous |
Next |
In an object-relational data-model, object arrays allow for an array of object types or structures to be embedded into a single column in a database table or an object table. OracleAS TopLink supports object array mappings to define a collection-aggregated relationship in which the target objects share the same row as the source object.
Object array mappings are instances of the ObjectArrayMapping
class. You must associate this mapping to an attribute in the parent class. OracleAS TopLink requires the following elements for an object 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.
Use the optional setGetMethodName( )
and setSetMethodName( )
messages to access the attribute through user-defined methods rather than directly. See "Specifying Direct Access and Method Access" on page 4-71 for more information. Table 7–2 summarizes all object array mapping properties.
Example 7-2 Object Array Mapping
The following code example illustrates creating an object array mapping for the Insurance
source class and registering it with the descriptor.
// Create a new mapping and register it with the source descriptor. ObjectArrayMapping phonesMapping = new ObjectArrayMapping(); phonesMapping.setAttributeName("phones"); phonesMapping.setGetMethodName("getPhones"); phonesMapping.setSetMethodName("setPhones"); phonesMapping.setStructureName("PHONELIST_TYPE"); phonesMapping.setReferenceClass(Phone.class); phonesMapping.setFieldName("PHONES"); descriptor.addMapping(phonesMapping);
The following table summarizes all object array mapping properties. In the Method Names column, arguments are bold, methods are not.
Table 7-2 Properties for ObjectArrayMapping 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)
|
Read only | read / write | readWrite ()
|