Skip Headers
Oracle TopLink Developer's Guide
10g Release 3 (10.1.3)
B13593-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
 

Configuring the Use of a Single Node

For the XML-based mappings that Table 35-6 summarizes, when you map a list value, you can configure whether or not the mapping unmarshalls (writes) the list to a single node, like <item>aaa bbb ccc</item>, or to multiple nodes, like:

<item>aaa</item>
<item>bbb</item>
<item>ccc</item>

Table 35-6 summarizes which mappings support this option.

Footnote 1 When used with XML records only (see "Configuring Record Format").

Using TopLink Workbench

To configure a mapping to use a single node, use this procedure.

  1. Select the mapped attribute in the Navigator. Its properties appear in the Editor.

  2. Click the General tab. The General tab appears.

    Figure 35-19 General Tab, Use Single Node Option

    Description of Figure 35-19 follows
    Description of "Figure 35-19 General Tab, Use Single Node Option"

To configure the mapping to unmarshall (write) a list value to a single node (like <item>aaa bbb ccc</item>), click Use single node.

By default, the mapping unmarshalls a list value to separate nodes.

Using Java

Use AbstractCompositeDirectCollectionMapping method setUsesSingleNode to configure the mapping to write a list value to a single node by passing in a value of true. To configure the mapping to write a list value to multiple nodes, pass in a value of false.

For any mapping that takes an XMLField, use XMLField method setUsesSingleNode to configure the mapping to write a list value to a single node by passing in a value of true. To configure the mapping to write a list value to multiple nodes, pass in a value of false. Example 35-17 shows how to use this method with an XMLDirectMapping:

Example 35-17 Using XMLField Method setUsesSingleNode

XMLDirectMapping tasksMapping = new XMLDirectMapping();
tasksMapping.setAttributeName("tasks");
XMLField myField = new XMLField("tasks/text()"); // pass in the XPath
myField.setUsesSingleNode(true);
tasksMapping.setField(myField);