|
Oracle TopLink Java API Reference 10g Release 3 (10.1.3.1) B28219-01 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.toplink.mappings.DatabaseMapping
oracle.toplink.mappings.AggregateMapping
oracle.toplink.mappings.foundation.AbstractCompositeObjectMapping
oracle.toplink.ox.mappings.XMLCompositeObjectMapping
Composite object XML mappings represent a relationship between two classes. In XML, the "owned" class may be nested with the element tag representing the "owning" class. This mapping is, by definition, privately owned.
Composite object XML mappings can be used in the following scenarios:
Setting the XPath: TopLink XML mappings make use of XPath statements to find the relevant data in an XML document. The XPath statement is relative to the context node specified in the descriptor. The XPath may contain path and positional information; the last node in the XPath forms the local root node for the composite object. The XPath is specified on the mapping using the setXPath
method.
The following XPath statements may be used to specify the location of XML data relating to an object's name attribute:
XPath | Description |
---|---|
. | Indicates "self". |
phone-number | The phone-number information is stored in the phone-number element. |
contact-info/phone-number | The XPath statement may be used to specify any valid path. |
phone-number[2] | The XPath statement may contain positional information. In this case the phone-number information is stored in the second occurrence of the phone-number element. |
Mapping into the Parent Record: The composite object may be mapped into the parent record in a corresponding XML document.
XML Schema
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element />
<xsd:complexType >
<xsd:sequence>
<xsd:element />
<xsd:element />
<xsd:element />
<xsd:element />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
Code Sample
XMLCompositeObjectMapping addressMapping = new XMLCompositeObjectMapping();
addressMapping.setAttributeName("address");
addressMapping.setXPath(".");
addressMapping.setReferenceClass(Address.class);
Mapping to an Element: The composite object may be mapped to an element in a corresponding XML document.
XML Schema
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element />
<xsd:complexType >
<xsd:sequence>
<xsd:element />
<xsd:element />
<xsd:element >
<xsd:complexType>
<xsd:sequence>
<xsd:element />
<xsd:element />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
Code Sample
XMLCompositeObjectMapping addressMapping = new XMLCompositeObjectMapping();
addressMapping.setAttributeName("address");
addressMapping.setXPath("address");
addressMapping.setReferenceClass(Address.class);
More Information: For more information about using the XML Composite Object Mapping, see the "Understanding XML Mappings" chapter of the Oracle TopLink Developer's Guide.
Constructor Summary | |
XMLCompositeObjectMapping() |
Method Summary | |
void |
configureNestedRow(DatabaseRow parent, DatabaseRow child) |
java.lang.String |
getXPath() Get the XPath String |
void |
setXPath(java.lang.String xpathString) Set the Mapping field name attribute to the given XPath String |
Methods inherited from class oracle.toplink.mappings.AggregateMapping |
getReferenceClass, setReferenceClass |
Methods inherited from class oracle.toplink.mappings.DatabaseMapping |
getAttributeAccessor, getAttributeClassification, getAttributeName, getGetMethodName, getProperty, getReferenceClassDescriptor, getSetMethodName, isUsingMethodAccess, readOnly, readWrite, setAttributeAccessor, setAttributeName, setGetMethodName, setIsReadOnly, setProperty, setSetMethodName, setWeight, simpleAddToCollectionChangeRecord, simpleRemoveFromCollectionChangeRecord |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public XMLCompositeObjectMapping()
Method Detail |
public java.lang.String getXPath()
public void setXPath(java.lang.String xpathString)
xpathString
- Stringpublic void configureNestedRow(DatabaseRow parent, DatabaseRow child)
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |