Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "EclipseLink/UserGuide/SDO/Introduction to EclipseLink SDO (ELUG)"
m (→Using SDO Metadata) |
m (→Using SDO Metadata) |
||
Line 3: | Line 3: | ||
==Using SDO Metadata== | ==Using SDO Metadata== | ||
− | SDO metadata is represented as <tt>[[#Using Type|Type]]</tt> and <tt>[[#Using Property|Property]]</tt> objects. You define the metadata at run time either programmatically, or from an XML schema ([[#How to Define Metadata with XSDHelper | using the XSDHelper]]. | + | SDO metadata is represented as <tt>[[#Using Type|Type]]</tt> and <tt>[[#Using Property|Property]]</tt> objects. You define the metadata at run time either programmatically, or from an XML schema ([[#How to Define Metadata with XSDHelper | using the XSDHelper]]). |
Revision as of 11:58, 29 April 2009
This section introduces EclipseLink implementation of Service Data Objects (SDO) specification, as well as provides information on how you can use it in your application development.
Contents
Using SDO Metadata
SDO metadata is represented as Type and Property objects. You define the metadata at run time either programmatically, or from an XML schema ( using the XSDHelper).
Using Type
SDO Type acts similarly to a Class in Java, and provides much of the same metadata as the Java Reflection API provides for Java classes.
In EclipseLink, a SDOType wraps an object-XML mapping (OXM) descriptor.
A Type can have supertypes, which corresponds to the EclipseLink concept of inheritance policy (see Inheritance Policy in Descriptor API).
For more information, see the default Type API.
What You May Need to Know About Open Sequenced Type
For information, see EclipseLink OpenSequencedType API.
What You May Need to Know About DataObjectType for Data Types
For information, see EclipseLink SDODataObjectType API.
Using Property
SDO Property acts similarly to a property in Java and provides much of the same metadata as the Java Reflection API provides for Java fields or methods.
In EclipseLink, a SDOProperty wraps an object-XML mapping in the following manner:
- DataType=true + isMany=false - corresponds to EclipseLink OXM direct mappings and OXM binary mappings.
- DataType=true + isMany=true - corresponds to EclipseLink OXM direct collection mappings and OXM binary collection mappings.
- DataType=false + isMany=false + containment=true - corresponds to EclipseLink OXM composite object mappings.
- DataType=false + isMany=true + containment=true - corresponds to EclipseLink OXM composite collection mappings.
- DataType=false + isMany=false + containment=false - corresponds to EclipseLink OXM reference mappings.
- DataType=false + isMany=true + containment=false - corresponds to EclipseLink OXM collection reference mappings.
For more information, see the default Property API.
Defining Metadata
You can use the following helper classes to define and access SDO metadata:
How to Define Metadata with XSDHelper
You use the XSDHelper to do the following:
- Define SDO metadata, where SDO metadata is derived from XML schemas.
- Generate XML schemas from SDO types.
For more information on how to use the XSDHelper in your application, see XSDHelper examples.
You can customize metadata by using the following annotations that you apply to the XML schema:
- Standard annotations:
- Information pending
- EclipseLink annotations:
- Information pending
You can also use various APIs to determine the XML representation about the SDO metadata.
For more information, see EclipseLink SDOXSDHelper API.
How to Define Metadata with EclipseLink TypeHelper
You use the TypeHelper to do the following:
- Look up SDO metadata.
- Programmatically define SDO metadata (note that this is not the typical usage for the TypeHelper).
For more information on how to use the TypeHelper in your application, see TypeHelper examples.
For more information, see EclipseLink SDOTypeHelper API.
Using Data
Use the following SDO classes to work with data:
Using DataObject
A DataObject in SDO corresponds to a Java Object (POJO). To define object-XML mappings, you map the DataObject to XML. You can create your data object as either dynamic (see Dynamic DataObject Examples), or static by applying a type-safe interface to it (see Static DataObject Examples).
The DataObject provides an XPath-like (see Mappings and XPath) means of data access. For example, the following code is valid in SDO:
customerDO.getDataObject("contact-info/phone-number[2]");
The standard JAXB, however, would require the following:
customer.getContactInfo().getPhoneNumbers().get(1);
Note that you can use the EclipseLink XPathHelper to query data objects using an XPath expression.
For more information, see EclipseLink SDODataObject API.
What You May Need to Know About Serialization in SDO
SDO has its own Java serialization format. The DataObject implements the Serializable interface.
Information pending.
Using XMLDocument
When you marshall (save) a DataObject to XML, or unmarshall an XML document into objects, the XMLDocument class contains information about the root of the XML document.
For more information, see EclipseLink SDOXMLDocument API.
What You May Need to Know About Sequence, ChangeSummary, and DataGraph
The following SDO classes allow you to obtain additional information about data objects:
- Sequence -- provides a list of properties and their corresponding values.
- ChangeSummary -- records changes to data objects, therefore reducing the amount of data that needs to be transmitted between collaborating SDO applications.
Note that the DataGraph class has been deprecated.
For more information, see the following EclipseLink APIs: