|
EclipseLink 2.4.2, build 'v20130514-5956486' API Reference | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.eclipse.persistence.mappings.DatabaseMapping
org.eclipse.persistence.mappings.AggregateMapping
org.eclipse.persistence.mappings.foundation.AbstractCompositeObjectMapping
org.eclipse.persistence.oxm.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.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.eclipse.persistence.mappings.DatabaseMapping |
|---|
DatabaseMapping.WriteType |
| Field Summary |
|---|
| Fields inherited from class org.eclipse.persistence.mappings.foundation.AbstractCompositeObjectMapping |
|---|
converter, field |
| Fields inherited from class org.eclipse.persistence.mappings.AggregateMapping |
|---|
referenceClass, referenceClassName, referenceDescriptor |
| Fields inherited from class org.eclipse.persistence.mappings.DatabaseMapping |
|---|
attributeAccessor, attributeName, derivedIdMapping, derivesId, descriptor, fields, isCacheable, isJPAId, isLazy, isMapKeyMapping, isOptional, isPrimaryKeyMapping, isReadOnly, isRemotelyInitialized, mapsIdValue, NO_FIELDS, NO_WEIGHT, properties, unconvertedProperties, weight, WEIGHT_AGGREGATE, WEIGHT_DIRECT, WEIGHT_TO_ONE, WEIGHT_TRANSFORM |
| Constructor Summary | |
|---|---|
XMLCompositeObjectMapping()
|
|
| Method Summary | |
|---|---|
protected java.lang.Object |
buildCompositeObject(org.eclipse.persistence.internal.descriptors.ObjectBuilder objectBuilder,
org.eclipse.persistence.internal.sessions.AbstractRecord nestedRow,
ObjectBuildingQuery query,
org.eclipse.persistence.internal.identitymaps.CacheKey parentCacheKey,
org.eclipse.persistence.internal.queries.JoinedAttributeManager joinManager,
org.eclipse.persistence.internal.sessions.AbstractSession targetSession)
|
protected java.lang.Object |
buildCompositeRow(java.lang.Object attributeValue,
org.eclipse.persistence.internal.sessions.AbstractSession session,
org.eclipse.persistence.internal.sessions.AbstractRecord databaseRow,
DatabaseMapping.WriteType writeType)
|
void |
configureNestedRow(org.eclipse.persistence.internal.sessions.AbstractRecord parent,
org.eclipse.persistence.internal.sessions.AbstractRecord child)
|
void |
convertClassNamesToClasses(java.lang.ClassLoader classLoader)
INTERNAL: Convert all the class-name-based settings in this mapping to actual class-based settings. |
AttributeAccessor |
getContainerAccessor()
Deprecated. Replaced by getInverseReferenceMapping().getAttributeAccessor() |
java.lang.String |
getContainerAttributeName()
Deprecated. Replaced by getInverseReferenceMapping().getAttributeName() |
java.lang.String |
getContainerGetMethodName()
Deprecated. Replaced by getInverseReferenceMapping().getGetMethodName() |
java.lang.String |
getContainerSetMethodName()
Deprecated. Replaced by getInverseReferenceMapping().getSetMethodName() |
protected XMLDescriptor |
getDescriptor(XMLRecord xmlRecord,
org.eclipse.persistence.internal.sessions.AbstractSession session,
javax.xml.namespace.QName rootQName)
|
XMLInverseReferenceMapping |
getInverseReferenceMapping()
|
UnmarshalKeepAsElementPolicy |
getKeepAsElementPolicy()
|
AbstractNullPolicy |
getNullPolicy()
INTERNAL: Get the AbstractNullPolicy from the Mapping. |
protected ClassDescriptor |
getReferenceDescriptor(java.lang.Class theClass,
org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: For inheritance purposes. |
ClassDescriptor |
getReferenceDescriptor(DOMRecord xmlRecord)
|
java.lang.String |
getXPath()
Get the XPath String |
void |
initialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: The mapping is initialized with the given session. |
boolean |
isWriteOnly()
INTERNAL: Some mappings support no attribute (transformation and multitenant primary key). |
boolean |
isXMLMapping()
INTERNAL: |
void |
preInitialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Allow for initialization of properties and validation. |
java.lang.Object |
readFromRowIntoObject(org.eclipse.persistence.internal.sessions.AbstractRecord databaseRow,
org.eclipse.persistence.internal.queries.JoinedAttributeManager joinManager,
java.lang.Object targetObject,
org.eclipse.persistence.internal.identitymaps.CacheKey parentCacheKey,
ObjectBuildingQuery sourceQuery,
org.eclipse.persistence.internal.sessions.AbstractSession executionSession,
boolean isTargetProtected)
INTERNAL: Extract value from the row and set the attribute to this value in the object. |
void |
setAttributeValueInObject(java.lang.Object object,
java.lang.Object value)
INTERNAL: Set the value of the attribute mapped by this mapping. |
void |
setContainerAccessor(AttributeAccessor anAttributeAccessor)
Deprecated. Replaced by getInverseReferenceMapping().setAttributeAccessor() |
void |
setContainerAttributeName(java.lang.String attributeName)
Deprecated. Replaced by getInverseReferenceMapping().setAttributeName() |
void |
setContainerGetMethodName(java.lang.String methodName)
Deprecated. Replaced by getInverseReferenceMapping().setGetMethodName() |
void |
setContainerSetMethodName(java.lang.String methodName)
Deprecated. Replaced by getInverseReferenceMapping().setSetMethodName() |
void |
setIsWriteOnly(boolean b)
|
void |
setKeepAsElementPolicy(UnmarshalKeepAsElementPolicy keepAsElementPolicy)
|
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(org.eclipse.persistence.internal.sessions.AbstractRecord row,
org.eclipse.persistence.internal.queries.JoinedAttributeManager joinManager,
ObjectBuildingQuery sourceQuery,
org.eclipse.persistence.internal.identitymaps.CacheKey cacheKey,
org.eclipse.persistence.internal.sessions.AbstractSession executionSession,
boolean isTargetProtected,
java.lang.Boolean[] wasCacheUsed)
INTERNAL: Extract and return the aggregate object from the specified row. |
java.lang.Object |
valueFromRow(java.lang.Object fieldValue,
XMLRecord nestedRow,
org.eclipse.persistence.internal.queries.JoinedAttributeManager joinManager,
ObjectBuildingQuery sourceQuery,
org.eclipse.persistence.internal.sessions.AbstractSession executionSession,
boolean isTargetProtected)
|
void |
writeFromObjectIntoRow(java.lang.Object object,
org.eclipse.persistence.internal.sessions.AbstractRecord databaseRow,
org.eclipse.persistence.internal.sessions.AbstractSession session,
DatabaseMapping.WriteType writeType)
INTERNAL: |
void |
writeSingleValue(java.lang.Object value,
java.lang.Object parent,
XMLRecord record,
org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: A method that marshals a single value to the provided Record based on this mapping's XPath. |
| Methods inherited from class org.eclipse.persistence.mappings.foundation.AbstractCompositeObjectMapping |
|---|
buildShallowOriginalFromRow, cascadeDiscoverAndPersistUnregisteredNewObjects, cascadePerformRemoveIfRequired, cascadeRegisterNewIfRequired, collectFields, getConverter, getField, hasConverter, isAbstractCompositeObjectMapping, setConverter, setField, valueFromObject, writeFromObjectIntoRowForUpdate, writeFromObjectIntoRowWithChangeRecord, writeInsertFieldsIntoRow |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public XMLCompositeObjectMapping()
| Method Detail |
|---|
@Deprecated public AttributeAccessor getContainerAccessor()
@Deprecated public void setContainerAccessor(AttributeAccessor anAttributeAccessor)
anAttributeAccessor - - the accessor to be used.@Deprecated public void setContainerAttributeName(java.lang.String attributeName)
attributeName - - the name of the backpointer attribute to be populated@Deprecated public java.lang.String getContainerAttributeName()
@Deprecated public void setContainerGetMethodName(java.lang.String methodName)
methodName - - the getter method to be used.@Deprecated public void setContainerSetMethodName(java.lang.String methodName)
methodName - - the setter method to be used.@Deprecated public java.lang.String getContainerGetMethodName()
@Deprecated public java.lang.String getContainerSetMethodName()
public void convertClassNamesToClasses(java.lang.ClassLoader classLoader)
AggregateMapping
convertClassNamesToClasses in interface XMLMappingconvertClassNamesToClasses in class AggregateMapping
public void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
throws DescriptorException
initialize in class AbstractCompositeObjectMappingDescriptorExceptionpublic void setNullPolicy(AbstractNullPolicy aNullPolicy)
setNullPolicy in interface XMLNillableMappingaNullPolicy - public AbstractNullPolicy getNullPolicy()
getNullPolicy in interface XMLNillableMappingpublic boolean isXMLMapping()
isXMLMapping in class DatabaseMappingpublic java.lang.String getXPath()
public void setXPath(java.lang.String xpathString)
xpathString - String
protected java.lang.Object buildCompositeRow(java.lang.Object attributeValue,
org.eclipse.persistence.internal.sessions.AbstractSession session,
org.eclipse.persistence.internal.sessions.AbstractRecord databaseRow,
DatabaseMapping.WriteType writeType)
buildCompositeRow in class AbstractCompositeObjectMapping
protected java.lang.Object buildCompositeObject(org.eclipse.persistence.internal.descriptors.ObjectBuilder objectBuilder,
org.eclipse.persistence.internal.sessions.AbstractRecord nestedRow,
ObjectBuildingQuery query,
org.eclipse.persistence.internal.identitymaps.CacheKey parentCacheKey,
org.eclipse.persistence.internal.queries.JoinedAttributeManager joinManager,
org.eclipse.persistence.internal.sessions.AbstractSession targetSession)
buildCompositeObject in class AbstractCompositeObjectMapping
public java.lang.Object readFromRowIntoObject(org.eclipse.persistence.internal.sessions.AbstractRecord databaseRow,
org.eclipse.persistence.internal.queries.JoinedAttributeManager joinManager,
java.lang.Object targetObject,
org.eclipse.persistence.internal.identitymaps.CacheKey parentCacheKey,
ObjectBuildingQuery sourceQuery,
org.eclipse.persistence.internal.sessions.AbstractSession executionSession,
boolean isTargetProtected)
throws DatabaseException
DatabaseMapping
readFromRowIntoObject in class DatabaseMappingDatabaseException
public java.lang.Object valueFromRow(java.lang.Object fieldValue,
XMLRecord nestedRow,
org.eclipse.persistence.internal.queries.JoinedAttributeManager joinManager,
ObjectBuildingQuery sourceQuery,
org.eclipse.persistence.internal.sessions.AbstractSession executionSession,
boolean isTargetProtected)
throws DatabaseException
DatabaseException
public java.lang.Object valueFromRow(org.eclipse.persistence.internal.sessions.AbstractRecord row,
org.eclipse.persistence.internal.queries.JoinedAttributeManager joinManager,
ObjectBuildingQuery sourceQuery,
org.eclipse.persistence.internal.identitymaps.CacheKey cacheKey,
org.eclipse.persistence.internal.sessions.AbstractSession executionSession,
boolean isTargetProtected,
java.lang.Boolean[] wasCacheUsed)
throws DatabaseException
AbstractCompositeObjectMapping
valueFromRow in class AbstractCompositeObjectMappingDatabaseException
public void writeFromObjectIntoRow(java.lang.Object object,
org.eclipse.persistence.internal.sessions.AbstractRecord databaseRow,
org.eclipse.persistence.internal.sessions.AbstractSession session,
DatabaseMapping.WriteType writeType)
throws DescriptorException
writeFromObjectIntoRow in class AbstractCompositeObjectMappingDescriptorException
public void writeSingleValue(java.lang.Object value,
java.lang.Object parent,
XMLRecord record,
org.eclipse.persistence.internal.sessions.AbstractSession session)
XMLMapping
writeSingleValue in interface XMLMappingvalue - - The value to be marshalledrecord - - The Record the value is being marshalled too.
public void configureNestedRow(org.eclipse.persistence.internal.sessions.AbstractRecord parent,
org.eclipse.persistence.internal.sessions.AbstractRecord child)
public ClassDescriptor getReferenceDescriptor(DOMRecord xmlRecord)
protected ClassDescriptor getReferenceDescriptor(java.lang.Class theClass,
org.eclipse.persistence.internal.sessions.AbstractSession session)
AggregateMapping
getReferenceDescriptor in class AggregateMappingpublic UnmarshalKeepAsElementPolicy getKeepAsElementPolicy()
public void setKeepAsElementPolicy(UnmarshalKeepAsElementPolicy keepAsElementPolicy)
protected XMLDescriptor getDescriptor(XMLRecord xmlRecord,
org.eclipse.persistence.internal.sessions.AbstractSession session,
javax.xml.namespace.QName rootQName)
throws XMLMarshalException
XMLMarshalExceptionpublic void setIsWriteOnly(boolean b)
setIsWriteOnly in interface XMLMappingpublic boolean isWriteOnly()
DatabaseMapping
isWriteOnly in interface XMLMappingisWriteOnly in class DatabaseMapping
public void preInitialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
throws DescriptorException
DatabaseMapping
preInitialize in class DatabaseMappingDescriptorException
public void setAttributeValueInObject(java.lang.Object object,
java.lang.Object value)
throws DescriptorException
AbstractCompositeObjectMapping
setAttributeValueInObject in class AbstractCompositeObjectMappingDescriptorExceptionpublic XMLInverseReferenceMapping getInverseReferenceMapping()
|
EclipseLink 2.4.2, build 'v20130514-5956486' API Reference | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||