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/Examples/SDO/JAXB"

(Create the JAXBHelperContext)
(Define the SDO Metadata)
Line 14: Line 14:
  
 
==Define the SDO Metadata==
 
==Define the SDO Metadata==
 +
An XML schema can be used to create the SDO metadata.  This is the same schema that the POJOs are mapped to.  This step has been separated so that SDO annotations could be added to the XML schema.
 +
<pre>
 +
jaxbHelperContext.getXSDHelper().define(xmlSchema);
 +
</pre>
  
 
==Get the SDO Type for a POJO==
 
==Get the SDO Type for a POJO==

Revision as of 11:36, 30 January 2009

Overview

The JAXBHelperContext is a bridge between POJOs and SDO DataObjects. The bridge is based on their corresponding XML representations. For the POJOs the XML representation is specified using JAXB annotations or object-to-XML mappings.

Create the JAXBHelperContext

The JAXBHelperContext is instantiated using a JAXBContext. This JAXBContext represents the object-to-XML mapping for the POJOs. If static DataObjects are being used, a second constructor is offered that takes a ClassLoader as a parameter.

JAXBContext jaxbContext = JAXBContext.newInstance("com.example.customer");
JAXBHelperContext jaxbHelperContext = new JAXBHelperContext(jaxbContext);

For help on creating a JAXBContext see:

Define the SDO Metadata

An XML schema can be used to create the SDO metadata. This is the same schema that the POJOs are mapped to. This step has been separated so that SDO annotations could be added to the XML schema.

jaxbHelperContext.getXSDHelper().define(xmlSchema);

Get the SDO Type for a POJO

Convert a POJO to a SDO DataObject

Convert a SDO DataObject to a POJO

Back to the top