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/FAQ/SDO"

 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
== What is SDO? ==
 
== What is SDO? ==
The Service Data Object (SDO) service allows developers to generate dynamic and static SDO models from an XSD and use these within their application. In addition to the XML binding capabilities defined in the specification additional flexibility is provided by the Object-XML service. This approach provides a solution for applications requiring less coupling to the data structures being accessed and modified. Support for wrapping a Java object (i.e. JPA entity) within a DataObject will be provided to enable the usage of existing domain models with SDO.
+
SDO is designed to be a unified view of data, much like the POJO is in Java EE.  There are several programming languages (of which Java is one) that support the SDO specification.
 +
 
 +
=== SDO as a Dynamic Object Model ===
 +
 
 +
SDO metadata is represented as Type and Property objects. A Type is comparable to a Java class, and a property to a Java field.  This metadata is defined at runtime either programmatically or from an XML schema.
 +
<source lang="java">
 +
Type customerType = TypeHelper.INSTANCE.getType(“urn:example”,  “customer”);
 +
Property firstNameProperty = customerType.getProperty(“first-name”);
 +
 
 +
Type addressType = TypeHelper.INSTANCE.getType(“urn:example”, “address”);
 +
</source>
 +
Data is represented as instances of Types called DataObjects, these correspond to objects in Java. DataObjects have many generic accessors that can be used to manipulate the data.
 +
<source lang="java">
 +
DataObject customerDO = DataFactory.INSTANCE.create(customerType);
 +
customerDO.setString(firstNameProperty, “Jane”);
 +
 
 +
DataObject addressDO = DataFactory.INSTANCE.create(“urn:example”, address);
 +
addressDO.set(“street”, “123 Any Street”);
 +
</source>
 +
 
 +
=== SDO as a Typed Object Model ===
 +
 
 +
SDO as dynamic object models is useful in certain frameworks (dynamic models allow metadata to be added without requiring a redeployment of the application), but in other situations a strongly typed model is required (typed models allow for code completion in an IDE).  A code generation step can be performed to produce typed interfaces complete with bean style accessors.
 +
<source lang="java">
 +
Customer customerDO = (Customer) DataFactory.INSTANCE.create(customerType);
 +
CustomerDO.setFirstName(“Jane”);
 +
</source>
 +
 
 +
=== SDO as an XML Representation ===
 +
 
 +
SDO has built in support for handling XML.  The SDO metadata can be introspected to determine what the corresponding XML representation is.
 +
<source lang="java">
 +
XSDHelper.INSTANCE.isMixed(customerType);
 +
XSDHelper.INSTANCE.isElement(firstNameProperty);
 +
</source>
 +
The DataObjects themselves can then be converted to from/XML
 +
<source lang="java">
 +
XMLHelper.INSTANCE.save(customerDO, “urn:example”, “customer”, System.out);
 +
</source>
 +
 
 +
=== SDO as a Disconnected Object ===
 +
 
 +
SDO was designed to represent disconnected data in a SCA (Service Component Architecture) environment. The main mechanism for accomplishing this goal is the ChangeSummary which tracks changes made to data objects over time (for DataObjects that have a ChangeSummary property).
 +
<source lang="java">
 +
List changed = customerDO.getChangeSummary().getChangedDataObjects();
 +
</source>
 +
 
 +
=== Summary ===
 +
EclipseLink is focussed on separating data from its messaging or persisted representations.  Now with SDO support this data can be a POJO or a DataObject.  This allows you to work with data in both Java EE and SCA environments.
  
 
== How do I use SDO? ==
 
== How do I use SDO? ==
 
The following examples demonstrate how to use EclipseLink SDO:
 
The following examples demonstrate how to use EclipseLink SDO:
 
* [[EclipseLink/Examples/SDO | SDO Examples]]
 
* [[EclipseLink/Examples/SDO | SDO Examples]]
 +
 +
== How do I use SDO to Interact with a Relational Database? ==
 +
EclipseLink provides an integration point between SDO and JPA.  For more informations see:
 +
* [[EclipseLink/Examples/SDO/JPA | Accessing Relational Data as SDO DataObjects using JPA]]
  
 
[[Category:EclipseLink FAQ|SDO]]
 
[[Category:EclipseLink FAQ|SDO]]

Latest revision as of 20:35, 3 August 2009

What is SDO?

SDO is designed to be a unified view of data, much like the POJO is in Java EE. There are several programming languages (of which Java is one) that support the SDO specification.

SDO as a Dynamic Object Model

SDO metadata is represented as Type and Property objects. A Type is comparable to a Java class, and a property to a Java field. This metadata is defined at runtime either programmatically or from an XML schema.

Type customerType = TypeHelper.INSTANCE.getType(“urn:example”,  “customer”);
Property firstNameProperty = customerType.getProperty(“first-name”);
 
Type addressType = TypeHelper.INSTANCE.getType(“urn:example”, “address”);

Data is represented as instances of Types called DataObjects, these correspond to objects in Java. DataObjects have many generic accessors that can be used to manipulate the data.

DataObject customerDO = DataFactory.INSTANCE.create(customerType);
customerDO.setString(firstNameProperty, “Jane”);
 
DataObject addressDO = DataFactory.INSTANCE.create(“urn:example”, address);
addressDO.set(“street”, “123 Any Street”);

SDO as a Typed Object Model

SDO as dynamic object models is useful in certain frameworks (dynamic models allow metadata to be added without requiring a redeployment of the application), but in other situations a strongly typed model is required (typed models allow for code completion in an IDE). A code generation step can be performed to produce typed interfaces complete with bean style accessors.

Customer customerDO = (Customer) DataFactory.INSTANCE.create(customerType);
CustomerDO.setFirstName(“Jane”);

SDO as an XML Representation

SDO has built in support for handling XML. The SDO metadata can be introspected to determine what the corresponding XML representation is.

XSDHelper.INSTANCE.isMixed(customerType);
XSDHelper.INSTANCE.isElement(firstNameProperty);

The DataObjects themselves can then be converted to from/XML

XMLHelper.INSTANCE.save(customerDO, “urn:example”, “customer”, System.out);

SDO as a Disconnected Object

SDO was designed to represent disconnected data in a SCA (Service Component Architecture) environment. The main mechanism for accomplishing this goal is the ChangeSummary which tracks changes made to data objects over time (for DataObjects that have a ChangeSummary property).

List changed = customerDO.getChangeSummary().getChangedDataObjects();

Summary

EclipseLink is focussed on separating data from its messaging or persisted representations. Now with SDO support this data can be a POJO or a DataObject. This allows you to work with data in both Java EE and SCA environments.

How do I use SDO?

The following examples demonstrate how to use EclipseLink SDO:

How do I use SDO to Interact with a Relational Database?

EclipseLink provides an integration point between SDO and JPA. For more informations see:

Back to the top