Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EclipseLink/UserGuide/SDO/Introduction to EclipseLink SDO (ELUG)"

m (How to Define Metadata with XSDHelper)
m (Defining Metadata)
Line 54: Line 54:
 
* <tt>[[#How to Define Metadata with TypeHelper| TypeHelper]]</tt>
 
* <tt>[[#How to Define Metadata with TypeHelper| TypeHelper]]</tt>
  
<!-- Information pending: modifying and accessing the underlying EclipseLink metadata -->
+
Information pending: modifying and accessing the underlying EclipseLink metadata
  
  
Line 64: Line 64:
 
You can obtain the default <tt>XSDHelper</tt> from the <tt>INSTANCE</tt> field or from the <tt>getDataHelper</tt> method of the default <tt>[http://www.eclipse.org/eclipselink/api/1.1/commonj/sdo/helper/HelperContext.html HelperContext]</tt>.
 
You can obtain the default <tt>XSDHelper</tt> from the <tt>INSTANCE</tt> field or from the <tt>getDataHelper</tt> method of the default <tt>[http://www.eclipse.org/eclipselink/api/1.1/commonj/sdo/helper/HelperContext.html HelperContext]</tt>.
  
You can also define and retrieve the <tt>HelperContext</tt> from your EclipseLink <tt>[http://www.eclipse.org/eclipselink/api/1.1/org/eclipse/persistence/sdo/helper/SDOXSDHelper.html SDOXSDHelper]</tt>.
 
  
For more information on how to use the <tt>XSDHelper</tt> in your application, see [http://wiki.eclipse.org/EclipseLink/Examples/SDO/BasicAPI#XSDHelper_-_Access_XML_Schema_Metadata EclipseLink XSDHelper examples].
+
 
 +
====How to Define Metadata with XSDHelper====
 +
You use the <tt>[http://www.eclipse.org/eclipselink/api/1.1/commonj/sdo/helper/XSDHelper.html XSDHelper]</tt> to do the following:
 +
* Define SDO metadata, where SDO metadata is derived from XML schemas.
 +
* Generate XML schemas from SDO types.
 +
 
 +
You can obtain the default <tt>XSDHelper</tt> from the <tt>INSTANCE</tt> field or from the <tt>getXSDHelper</tt> method of the default <tt>[http://www.eclipse.org/eclipselink/api/1.1/commonj/sdo/helper/HelperContext.html HelperContext]</tt>.
  
 
You can customize metadata by using the following annotations that you apply to the XML schema:
 
You can customize metadata by using the following annotations that you apply to the XML schema:
Line 77: Line 82:
  
 
You can also use various APIs to determine the XML representation about the SDO metadata.
 
You can also use various APIs to determine the XML representation about the SDO metadata.
 +
 +
For more information, see the following:
 +
* EclipseLink <tt>[http://www.eclipse.org/eclipselink/api/1.1/org/eclipse/persistence/sdo/helper/SDOXSDHelper.html SDOXSDHelper]</tt> API
 +
* [http://wiki.eclipse.org/EclipseLink/Examples/SDO/BasicAPI#XSDHelper_-_Access_XML_Schema_Metadata XSDHelper examples]
 +
 +
  
 
====How to Define Metadata with EclipseLink TypeHelper====
 
====How to Define Metadata with EclipseLink TypeHelper====
Line 82: Line 93:
 
* Look up SDO metadata.
 
* Look up SDO metadata.
 
* Programmatically define SDO metadata (note that this is not the typical usage for the <tt>TypeHelper</tt>).
 
* Programmatically define SDO metadata (note that this is not the typical usage for the <tt>TypeHelper</tt>).
 +
 +
You can obtain the default <tt>TypeHelper</tt> from the <tt>INSTANCE</tt> field or from the <tt>getTypeHelper</tt> method of the default <tt>[http://www.eclipse.org/eclipselink/api/1.1/commonj/sdo/helper/HelperContext.html HelperContext]</tt>.
  
 
For more information on how to use the <tt>TypeHelper</tt> in your application, see [http://wiki.eclipse.org/EclipseLink/Examples/SDO/BasicAPI#TypeHelper_-_Access_Metadata TypeHelper examples].
 
For more information on how to use the <tt>TypeHelper</tt> in your application, see [http://wiki.eclipse.org/EclipseLink/Examples/SDO/BasicAPI#TypeHelper_-_Access_Metadata TypeHelper examples].
  
 
For more information, see EclipseLink <tt>[http://www.eclipse.org/eclipselink/api/1.1/org/eclipse/persistence/sdo/helper/SDOTypeHelper.html SDOTypeHelper]</tt> API.
 
For more information, see EclipseLink <tt>[http://www.eclipse.org/eclipselink/api/1.1/org/eclipse/persistence/sdo/helper/SDOTypeHelper.html SDOTypeHelper]</tt> API.
 
 
  
 
==Using Data==
 
==Using Data==

Revision as of 10:13, 1 May 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.


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).

To create types programmatically, you populate a DataObject with them.

To load types from an XML schema, use the XSDHelper class, as the following example shows:

HelperContext ctx = HelperProvider.getDefaultContext();
FileInputStream is = new FileInputStream("test.xsd");
ctx.getXSDHelper().define(is, null);

For more information, see the default Type API.


What You May Need to Know About Open Sequenced Type

You can define SDO types as open sequenced types. If, when creating a DataObject, you define a Type as a sequenced type (that is, isSequenced is true), then the created DataObject is put at the end of the Sequence.

If you define a Type as open (that is, its open is true), it will have to accept additional DataObject's properties (the ones not specified by their Type).

For more information, see EclipseLink OpenSequencedType API.

What You May Need to Know About DataObjectType for Data Types

For information, see EclipseLink SDODataObjectType API.


Using Property

A DataObject is made up of Property values. 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:

For more information, see the default Property API.

Defining Metadata

You can use the following helper classes to define and access SDO metadata:

Information pending: modifying and accessing the underlying EclipseLink 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.

You can obtain the default XSDHelper from the INSTANCE field or from the getDataHelper method of the default HelperContext.


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.

You can obtain the default XSDHelper from the INSTANCE field or from the getXSDHelper method of the default HelperContext.

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 the following:


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).

You can obtain the default TypeHelper from the INSTANCE field or from the getTypeHelper method of the default HelperContext.

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. You can serialize SDO to XML using the XMLHelper interface that provides methods for serializing DataObject or XMLDocument instances to XML.


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:



Copyright Statement

Back to the top