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 SDO (ELUG)"

m (XML Representation)
(Typed Object Model)
 
(13 intermediate revisions by 2 users not shown)
Line 6: Line 6:
 
SDO is designed to be a unified view of data, similarly to POJO in Java EE. There are several programming languages (of which Java is one) that support the SDO specification.
 
SDO is designed to be a unified view of data, similarly to POJO in Java EE. There are several programming languages (of which Java is one) that support the SDO specification.
  
You can use SDO to develop data-oriented applications. SDO includes an architecture and API.
+
You can use SDO to develop data-oriented applications. SDO includes an architecture and an API.
  
 
The following are possible expressions of SDO:
 
The following are possible expressions of SDO:
Line 14: Line 14:
 
* [[#Disconnected Object|Disconnected Object]]  
 
* [[#Disconnected Object|Disconnected Object]]  
  
For more information, see [http://www.osoa.org/display/Main/Service+Data+Objects+Specifications SDO Specification].
+
For more information, see [http://jcp.org/en/jsr/detail?id=235 SDO Specification].
  
  
Line 25: Line 25:
 
   
 
   
 
  Type addressType = TypeHelper.INSTANCE.getType(“urn:example”, “address”);
 
  Type addressType = TypeHelper.INSTANCE.getType(“urn:example”, “address”);
+
 
 
Data is represented as instances of <tt>Type</tt> called <tt>[http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.emf.ecore.sdo.doc/references/javadoc/commonj/sdo/DataObject.html DataObject]</tt>. The <tt>DataObject</tt> in SDO corresponds to a Java <tt>Object</tt> and have many generic accessors that you can use to manipulate the data, as the following example shows:
 
Data is represented as instances of <tt>Type</tt> called <tt>[http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.emf.ecore.sdo.doc/references/javadoc/commonj/sdo/DataObject.html DataObject]</tt>. The <tt>DataObject</tt> in SDO corresponds to a Java <tt>Object</tt> and have many generic accessors that you can use to manipulate the data, as the following example shows:
 
   
 
   
Line 33: Line 33:
 
  DataObject addressDO = DataFactory.INSTANCE.create(“urn:example”, address);
 
  DataObject addressDO = DataFactory.INSTANCE.create(“urn:example”, address);
 
  addressDO.set(“street”, “123 Any Street”);
 
  addressDO.set(“street”, “123 Any Street”);
 +
 +
A <tt>DataObject</tt>'s properties can contain simple values, other data objects, or <tt>List</tt>s of simple values or <tt>DataObject</tt>s. Data objects can contain references to other data objects, or they can contain them.
  
 
===Typed Object Model===
 
===Typed Object Model===
Line 39: Line 41:
 
  Customer customerDO = (Customer) DataFactory.INSTANCE.create(customerType);
 
  Customer customerDO = (Customer) DataFactory.INSTANCE.create(customerType);
 
  CustomerDO.setFirstName(“Jane”);
 
  CustomerDO.setFirstName(“Jane”);
 +
 +
For more information, see the [[EclipseLink/Examples/SDO/Compiler | Running the SDO Compiler - Generating Type Safe DataObjects]] and [[EclipseLink/Examples/SDO/StaticAPI | Using Type Safe DataObjects to Manipulate XML]] examples.
  
 
===XML Representation===
 
===XML Representation===
Line 49: Line 53:
  
 
  XMLHelper.INSTANCE.save(customerDO, “urn:example”, “customer”, System.out);
 
  XMLHelper.INSTANCE.save(customerDO, “urn:example”, “customer”, System.out);
 +
 +
For more information, see the following:
 +
* [http://wiki.eclipse.org/EclipseLink/UserGuide/SDO/Introduction_to_EclipseLink_SDO_%28ELUG%29#How_to_Define_Metadata_with_XSDHelper How to Define Metadata with XSDHelper]
 +
* [http://wiki.eclipse.org/EclipseLink/UserGuide/SDO/Using_EclipseLink_SDO_%28ELUG%29#Using_XMLHelper Using XMLHelper]
  
 
===Disconnected Object===
 
===Disconnected Object===
Line 55: Line 63:
 
  List changed = customerDO.getChangeSummary().getChangedDataObjects();
 
  List changed = customerDO.getChangeSummary().getChangedDataObjects();
  
EclipseLink is focussed on separating data from its messaging or persisted representations. With SDO support this data can be a POJO or a DataObject, which allows you to work with data in both Java EE and SCA environments.
+
EclipseLink is focused on separating data from its messaging or persisted representations. With SDO support this data can be a POJO or a data object, which allows you to work with data in both Java EE and SCA environments.
  
  

Latest revision as of 11:35, 21 May 2009

This section introduces concepts of Service Data Objects (SDO) and provides general information on it.


What Is SDO?

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

You can use SDO to develop data-oriented applications. SDO includes an architecture and an API.

The following are possible expressions of SDO:

For more information, see SDO Specification.


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. You define this metadata at run time either programmatically or from an XML schema, as follows:

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 Type called DataObject. The DataObject in SDO corresponds to a Java Object and have many generic accessors that you can use to manipulate the data, as the following example shows:

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

A DataObject's properties can contain simple values, other data objects, or Lists of simple values or DataObjects. Data objects can contain references to other data objects, or they can contain them.

Typed Object Model

SDO as a dynamic object model is useful in certain frameworks based on the fact that dynamic models let you add metadata without requiring a redeployment of your application. However, in some cases a strongly typed model is required that allows for code completion in an IDE. You can perform a code generation step to produce typed interfaces complete with bean-style accessors, as the following example shows:

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

For more information, see the Running the SDO Compiler - Generating Type Safe DataObjects and Using Type Safe DataObjects to Manipulate XML examples.

XML Representation

SDO has a built-in support for handling XML. You can introspect the SDO metadata to determine the corresponding XML representation, as the following EclipseLink example shows:

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

You can then convert the DataObject instances to and from XML, as follows:

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

For more information, see the following:

Disconnected Object

SDO was designed to represent disconnected data in a Service Component Architecture (SCA) environment. You can do so by using the ChangeSummary that tracks changes made to data objects over time. Note that this applies to DataObject instances that have a ChangeSummary property. Consider the following example:

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

EclipseLink is focused on separating data from its messaging or persisted representations. With SDO support this data can be a POJO or a data object, which allows you to work with data in both Java EE and SCA environments.



Copyright Statement

Back to the top