|
Oracle Fusion Middleware Java API Reference for Oracle TopLink 11g Release 1 (11.1.1) B32476-03 |
||||||||
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
public class 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 name="customer" type="customer-type"/>
<xsd:complexType name="customer-type">
<xsd:sequence>
<xsd:element name="first-name" type="xsd:string"/>
<xsd:element name="last-name" type="xsd:string"/>
<xsd:element name="street" type="xsd:string"/>
<xsd:element name="city" type="xsd:string"/>
</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 name="customer" type="customer-type"/>
<xsd:complexType name="customer-type">
<xsd:sequence>
<xsd:element name="first-name" type="xsd:string"/>
<xsd:element name="last-name" type="xsd:string"/>
<xsd:element name="address">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="street" type="xsd:string"/>
<xsd:element name="city" type="xsd:string"/>
</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(oracle.toplink.internal.sessions.AbstractRecord parent,
oracle.toplink.internal.sessions.AbstractRecord child)
|
ClassDescriptor |
getReferenceDescriptor(DOMRecord xmlRecord)
|
java.lang.String |
getXPath()
Get the XPath String |
void |
setNullPolicy(AbstractNullPolicy aNullPolicy)
Set the AbstractNullPolicy on the mapping The default policy is NullPolicy. |
void |
setXPath(java.lang.String xpathString)
Set the Mapping field name attribute to the given XPath String |
java.lang.Object |
valueFromRow(java.lang.Object fieldValue,
XMLRecord nestedRow,
oracle.toplink.internal.queryframework.JoinedAttributeManager joinManager,
ObjectBuildingQuery sourceQuery,
oracle.toplink.internal.sessions.AbstractSession executionSession)
|
Methods inherited from class oracle.toplink.mappings.foundation.AbstractCompositeObjectMapping |
---|
getConverter, hasConverter, setConverter, setField |
Methods inherited from class oracle.toplink.mappings.AggregateMapping |
---|
getReferenceClass, setReferenceClass |
Methods inherited from class oracle.toplink.mappings.DatabaseMapping |
---|
getAttributeAccessor, getAttributeClassification, getAttributeName, getGetMethodName, getProperty, getSetMethodName, isLazy, isOptional, isUsingMethodAccess, readOnly, readWrite, setAttributeAccessor, setAttributeName, setGetMethodName, setIsLazy, setIsOptional, 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 void setNullPolicy(AbstractNullPolicy aNullPolicy)
setNullPolicy
in interface oracle.toplink.ox.mappings.XMLNillableMapping
aNullPolicy
- public java.lang.String getXPath()
public void setXPath(java.lang.String xpathString)
xpathString
- Stringpublic java.lang.Object valueFromRow(java.lang.Object fieldValue, XMLRecord nestedRow, oracle.toplink.internal.queryframework.JoinedAttributeManager joinManager, ObjectBuildingQuery sourceQuery, oracle.toplink.internal.sessions.AbstractSession executionSession) throws DatabaseException
DatabaseException
public void configureNestedRow(oracle.toplink.internal.sessions.AbstractRecord parent, oracle.toplink.internal.sessions.AbstractRecord child)
public ClassDescriptor getReferenceDescriptor(DOMRecord xmlRecord)
|
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |