| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
| "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" /> |
| <meta http-equiv="Content-Style-Type" content="text/css" /> |
| <meta http-equiv="Content-Script-Type" content="text/javascript" /> |
| <title>Understanding XML-to-Relational Mapping (XRM) | EclipseLink 3.0 EclipseLink DBWS</title> |
| <meta name="generator" content="Oracle DARB XHTML Converter (Mode = document) - Version 1.0.22 Build 1" /> |
| <meta name="date" content="2014-06-10T10:32:28Z" /> |
| <meta name="robots" content="noarchive" /> |
| <meta name="doctitle" content="Understanding XML-to-Relational Mapping (XRM)" /> |
| <meta name="relnum" content="Release 3.0" /> |
| <link rel="stylesheet" type="text/css" href="../../dcommon/style.css" media="screen" /> |
| <link rel="copyright" href="../../dcommon/html/cpyr.htm" title="Copyright" type="text/html" /> |
| <link rel="start" href="../../index.htm" title="Home" type="text/html" /> |
| <link rel="contents" href="toc.htm" title="Contents" type="text/html" /> |
| <link rel="prev" href="overview.htm" title="Previous" type="text/html" /> |
| <link rel="next" href="overview002.htm" title="Next" type="text/html" /> |
| <!-- START: Disqus --><script type="text/javascript"> var disqus_developer = 0; </script><!-- END: Disqus --><!-- START: Sharethis --><script type="text/javascript">var switchTo5x=true;</script><script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script><script type="text/javascript" src="http://s.sharethis.com/loader.js"></script> <!-- END: Sharethis --></head> |
| <body bgcolor="#FFFFFF"><iframe id="docheader" frameborder="0" framemargin="0" scrolling="no" src="../../dcommon/header.html"></iframe><script src="http://www.google.com/jsapi" type="text/javascript"></script><script type="text/javascript"> google.load('search', '1', {language : 'en'}); google.setOnLoadCallback(function() { var customSearchOptions = {}; var googleAnalyticsOptions = {}; googleAnalyticsOptions['queryParameter'] = 'q'; googleAnalyticsOptions['categoryParameter'] = ''; customSearchOptions['googleAnalyticsOptions'] = googleAnalyticsOptions; var customSearchControl = new google.search.CustomSearchControl( '016171230611334810008:1hjujor5_fg', customSearchOptions); customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET); var options = new google.search.DrawOptions(); options.setSearchFormRoot('cse-search-form'); customSearchControl.draw('cse', options); }, true);</script><link rel="stylesheet" href="http://www.google.com/cse/style/look/default.css" type="text/css" /><div id="cse" style="width:100%;"></div> |
| <div class="header"><a id="top" name="top"></a> |
| <table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%"> |
| <tr> |
| <td align="left" valign="top"><font face="helvetica, arial, sans-serif"><b>Developing Persistence Architectures Using EclipseLink Database Web Services</b><br /> |
| <b>Release 3.0</b><br /> |
| </font></td> |
| <td valign="bottom" align="right" width="144"> |
| <table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%"> |
| <tr> |
| <td> </td> |
| <td align="center" valign="top"><a href="toc.htm"><img src="../../dcommon/images/contents.png" alt="Go To Table Of Contents" border="0" height="16" width="16" /><br /> |
| </td><td> </td><td align="center"><a href="../../" target="_top" class="external text" title="Search" rel="nofollow"><img src="../../dcommon/images/search.png" alt="Search" style="border:0;" /><br /><span class="mini"></span></a></td><td> </td><td align="center"><a href="../eclipselink_moxy.pdf" title="PDF" target="_blank"><img src="../../dcommon/images/pdf_icon.png" style="padding-right:5px;border:0" alt="PDF"></a></td> |
| </tr> |
| </table> |
| </td> |
| </tr> |
| </table> |
| <hr /> |
| <table class="navigation simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100" align="center"> |
| <tr> |
| <td align="center"><a href="overview.htm"><img src="../../dcommon/images/larrow.png" alt="Previous" border="0" height="16" width="16" /></a></td> |
| <td align="center"><a href="overview002.htm"><img src="../../dcommon/images/rarrow.png" alt="Next" border="0" height="16" width="16" /></a></td> |
| <td> </td> |
| </tr> |
| </table> |
| </div> |
| <!-- class="header" --> |
| <div class="ind"><!-- End Header --><a id="CJAFEHEG" name="CJAFEHEG"></a><a id="TLDBW110" name="TLDBW110"></a> |
| <div class="sect1"> |
| <h1 class="sect1"><font face="arial, helvetica, sans-serif" color="#330099">Understanding XML-to-Relational Mapping (XRM)</font></h1> |
| <p>EclipseLink's ORM and OXM features provides the basis for a powerful bridge between a database's relational structure(s) and XML's hierarchical structure.</p> |
| <div class="figure"><a id="TLDBW111" name="TLDBW111"></a><a id="sthref7" name="sthref7"></a> |
| <p><strong><em><font face="arial, helvetica, sans-serif">Figure 1-1 EclipseLink XR Architecture</font></em></strong></p> |
| <img src="img/chart_v2.gif" alt="Description of Figure 1-1 follows" title="Description of Figure 1-1 follows" longdesc="img_text/chart_v2.htm" /><br /> |
| <a id="sthref8" name="sthref8" href="img_text/chart_v2.htm">Description of "Figure 1-1 EclipseLink XR Architecture"</a><br /> |
| <br /></div> |
| <!-- class="figure" --> |
| <a id="TLDBW112" name="TLDBW112"></a> |
| <div class="sect2"><a id="sthref9" name="sthref9"></a> |
| <h2 class="sect2"><font face="arial, helvetica, sans-serif" color="#330099">Configuration</font></h2> |
| <p>A typical EclipseLink DBWS service is packaged in an archive (<code>.jar</code> or <code>.war</code> file) with a service descriptor file <code>eclipselink-dbws.xml</code> in the <code>META-INF</code> directory (or <code>WEB-INF/classes/META-INF</code> when packaged in a <code>.war</code> file). To bridge the relational database and XML worlds, an EclipseLink <code>sessions.xml</code> (<code>eclipselink-dbws-sessions.xml</code>) points to two Eclipse projects: one for the ORM side, the other for the OXM side. The service also requires an XML Schema Definition file <code>eclipselink-dbws-schema.xsd</code> which in conjunction with the OXM project, specifies how information from the database is to be "shaped" into XML documents.</p> |
| <div class="figure"><a id="TLDBW113" name="TLDBW113"></a><a id="sthref10" name="sthref10"></a> |
| <p><strong><em><font face="arial, helvetica, sans-serif">Figure 1-2 Typical EclipseLink DBWS Service Files</font></em></strong></p> |
| <img src="img/dbwsservicepackage.gif" alt="Typical EclipseLink DBWS Service Files" title="Typical EclipseLink DBWS Service Files" longdesc="img_text/dbwsservicepackage.htm" /><br /> |
| <a id="sthref11" name="sthref11" href="img_text/dbwsservicepackage.htm">Description of "Figure 1-2 Typical EclipseLink DBWS Service Files"</a><br /> |
| <br /></div> |
| <!-- class="figure" --> |
| <div align="center"> |
| <div class="inftblnote"><br /> |
| <table class="Note oac_no_warn" summary="" border="1" width="80%" frame="hsides" rules="groups" cellpadding="3" cellspacing="0"> |
| <tbody> |
| <tr> |
| <td align="left"> |
| <p class="note"><img src="../../dcommon/images/note_icon.png" width="16" height="16" alt="Note" style="vertical-align:middle;padding-right:5px;" />Note:</p> |
| <p>Not all files are displayed.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| <br /></div> |
| <!-- class="inftblnote" --></div> |
| <p>The EclipseLink DBWS service descriptor file, <code>eclipselink-dbws.xml</code>, is easy to read, with minimal required information and simple defaults for omitted fields. This allows for auto-generation by a utility or manual editing. <a href="#CJADJDDA">Example 1-1</a> illustrates a sample DBWS service descriptor file.</p> |
| <div class="example"><a id="CJADJDDA" name="CJADJDDA"></a><a id="TLDBW114" name="TLDBW114"></a> |
| <p><strong><em><font face="arial, helvetica, sans-serif">Example 1-1 Example DBWS Service descriptor file</font></em></strong></p> |
| <pre xml:space="preserve" class="oac_no_warn"> |
| <?xml version="1.0" encoding="UTF-8"?> |
| <dbws |
| xmlns:xsd="http://www.w3.org/2001/XMLSchema" |
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| > |
| <<strong>name</strong>>example</<strong>name</strong>> |
| <<strong>sessions-file</strong>>example-dbws-sessions.xml</<strong>sessions-file</strong>> |
| <query> |
| <name>countEmployees |
| <result> |
| <type>xsd:int</type> |
| </result> |
| <sql><!--[CDATA[select count(*) from EMP]]--></sql> |
| </query> |
| </dbws> |
| |
| </pre></div> |
| <!-- class="example" --> |
| <p><a href="#CJAHDJAB">Table 1-1</a> describes the elements of the EclipseLink DBWS service descriptor file.</p> |
| <div class="tblhruleformalwide"><a id="TLDBW115" name="TLDBW115"></a><a id="sthref12" name="sthref12"></a><a id="CJAHDJAB" name="CJAHDJAB"></a> |
| <p><strong><em><font face="arial, helvetica, sans-serif">Table 1-1 EclipseLink DBWS Service Descriptor File Elements</font></em></strong></p> |
| <table class="HRuleFormalWide" title="EclipseLink DBWS Service Descriptor File Elements" summary="This table describes the EclipseLink DBWS service descriptor file elements. Additionally, it indicates if the element is required and what the default value is." dir="ltr" border="1" width="100%" frame="hsides" rules="rows" cellpadding="3" cellspacing="0"> |
| <col width="21%" /> |
| <col width="23%" /> |
| <col width="25%" /> |
| <col width="*" /> |
| <thead> |
| <tr align="left" valign="top"> |
| <th align="left" valign="bottom" id="r1c1-t3"><font face="Arial, Helvetica, sans-serif"><strong>Element</strong></font></th> |
| <th align="left" valign="bottom" id="r1c2-t3"><font face="Arial, Helvetica, sans-serif"><strong>Description</strong></font></th> |
| <th align="left" valign="bottom" id="r1c3-t3"><font face="Arial, Helvetica, sans-serif"><strong>Required?</strong></font></th> |
| <th align="left" valign="bottom" id="r1c4-t3"><font face="Arial, Helvetica, sans-serif"><strong>Default</strong></font></th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr align="left" valign="top"> |
| <td align="left" id="r2c1-t3" headers="r1c1-t3"> |
| <p><code>name</code></p> |
| </td> |
| <td align="left" headers="r2c1-t3 r1c2-t3"> |
| <p>Name of the EclipseLink DBWS service.</p> |
| </td> |
| <td align="left" headers="r2c1-t3 r1c3-t3"> |
| <p>Yes, set by the <code>projectName</code> property in the <code>DBWSBuilder</code>.</p> |
| </td> |
| <td align="left" headers="r2c1-t3 r1c4-t3"> |
| <p>None</p> |
| </td> |
| </tr> |
| <tr align="left" valign="top"> |
| <td align="left" id="r3c1-t3" headers="r1c1-t3"> |
| <p><code>sessions-file</code></p> |
| </td> |
| <td align="left" headers="r3c1-t3 r1c2-t3"> |
| <p>Name of the EclipseLink <code>sessions.xml</code> file.</p> |
| </td> |
| <td align="left" headers="r3c1-t3 r1c3-t3"> |
| <p>No</p> |
| </td> |
| <td align="left" headers="r3c1-t3 r1c4-t3"> |
| <p><code>eclipselink-dbws-sessions.xml</code></p> |
| </td> |
| </tr> |
| <tr align="left" valign="top"> |
| <td align="left" id="r4c1-t3" headers="r1c1-t3"> |
| <p>Any of the following:</p> |
| <ul> |
| <li> |
| <p><code>insert</code></p> |
| </li> |
| <li> |
| <p><code>update</code></p> |
| </li> |
| <li> |
| <p><code>delete</code></p> |
| </li> |
| <li> |
| <p><code>query</code></p> |
| </li> |
| </ul> |
| </td> |
| <td align="left" headers="r4c1-t3 r1c2-t3"> |
| <p>Service operations</p> |
| </td> |
| <td align="left" headers="r4c1-t3 r1c3-t3"> |
| <p>At least one operation</p> |
| </td> |
| <td align="left" headers="r4c1-t3 r1c4-t3"> |
| <p>None</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| <br /></div> |
| <!-- class="tblhruleformalwide" --></div> |
| <!-- class="sect2" --> |
| <a id="TLDBW116" name="TLDBW116"></a> |
| <div class="sect2"><a id="sthref13" name="sthref13"></a> |
| <h2 class="sect2"><font face="arial, helvetica, sans-serif" color="#330099">XML Schema Definition</font></h2> |
| <p>The EclipseLink DBWS service schema file <code>eclipselink-dbws-schema.xsd</code> can be created by hand, or auto-generated by the design-time <code>DBWSBuilder</code> utility that derives XML element-tag names from Database metadata (column names, types, nullable, and so on).</p> |
| <p>The DBWSBuilder utility will not generate an XML Schema Definition when the information returned by a query operation has no pre-determined structure, such as:</p> |
| <ul> |
| <li> |
| <p>a <code>resultSet</code> from a custom SQL <strong>query operation</strong></p> |
| </li> |
| <li> |
| <p>the results from a Stored Procedure <strong>query operation</strong></p> |
| </li> |
| <li> |
| <p>the row-count from an <strong>update</strong> <strong>operation</strong></p> |
| </li> |
| </ul> |
| <p>In these cases, the EclipseLink DBWS runtime provider uses information only available at the time of query execution to build the XML document:</p> |
| <div class="example"><a id="TLDBW117" name="TLDBW117"></a><a id="sthref14" name="sthref14"></a> |
| <p><strong><em><font face="arial, helvetica, sans-serif">Example 1-2 Example Simple XML Format (SXF) document</font></em></strong></p> |
| <p>Element tag names are direct copies of table's column names.</p> |
| <pre xml:space="preserve" class="oac_no_warn"> |
| <?xml version = '1.0' encoding = 'UTF-8'?> |
| <simple-xml-format> |
| <simple-xml> |
| <EMPNO>7788</EMPNO> |
| <ENAME>SCOTT</ENAME> |
| <JOB>ANALYST</JOB> |
| <MGR>7566</MGR> |
| <HIREDATE>1987-04-19T00:00:00.000-0400</HIREDATE> |
| <SAL>3000</SAL> |
| <DEPTNO>20</DEPTNO> |
| </simple-xml> |
| <simple-xml> |
| <EMPNO>7369</EMPNO> |
| <ENAME>SMITH</ENAME> |
| <JOB>CLERK</JOB> |
| <MGR>7902</MGR> |
| <HIREDATE>1980-12-17T00:00:00.000-0400</HIREDATE> |
| <SAL>800</SAL> |
| <DEPTNO>20</DEPTNO> |
| </simple-xml> |
| </simple-xml-format> |
| |
| </pre> |
| <p>These XML documents are "dumb," as they cannot be validated against any pre-determined schema - or more accurately, only the following very <em>permissive</em> "sequence-of-any" schema can validate such documents:</p> |
| </div> |
| <!-- class="example" --> |
| <div class="example"><a id="TLDBW118" name="TLDBW118"></a><a id="sthref15" name="sthref15"></a> |
| <p><strong><em><font face="arial, helvetica, sans-serif">Example 1-3 Simple XML Format Schema</font></em></strong></p> |
| <pre xml:space="preserve" class="oac_no_warn"> |
| <?xml version="1.0" encoding="UTF-8"?> |
| <xsd:schema |
| xmlns:xsd="http://www.w3.org/2001/XMLSchema" |
| > |
| <xsd:complexType name="simple-xml-format"> |
| <xsd:sequence> |
| <xsd:any minOccurs="0"/> |
| </xsd:sequence> |
| </xsd:complexType> |
| </xsd:schema> |
| |
| </pre> |
| <p>The element tags <code>simple-xml-forma</code>t and <code>simple-xml</code> can be customized by setting the appropriate properties on an <strong>operation</strong>.</p> |
| </div> |
| <!-- class="example" --></div> |
| <!-- class="sect2" --></div> |
| <!-- class="sect1" --></div> |
| <!-- class="ind" --> |
| <!-- Start Footer --> |
| <div class="footer"> |
| <hr /> |
| <table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%"> |
| <col width="33%" /> |
| <col width="*" /> |
| <col width="33%" /> |
| <tr> |
| <td valign="bottom"> |
| <table class="navigation simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100" align="center"> |
| <col width="*" /> |
| <col width="48%" /> |
| <col width="48%" /> |
| <tr> |
| <td> </td> |
| <td align="center"><a href="overview.htm"><img src="../../dcommon/images/larrow.png" alt="Previous" border="0" height="16" width="16" /></a></td> |
| <td align="center"><a href="overview002.htm"><img src="../../dcommon/images/rarrow.png" alt="Next" border="0" height="16" width="16" /></a></td> |
| </tr> |
| </table> |
| </td> |
| <td align="center" width="34%"><a href="http://www.eclipse.org/eclipselink/" title="EclipseLink home"><img src="../../dcommon/images/ellogo.png" alt="EclipseLink" width="150" border="0" /></a><br /> |
| |
| |
| <td valign="bottom" align="right"> |
| <table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="225"> |
| <tr> |
| <td> </td> |
| <td align="center" valign="top"><a href="toc.htm"><img src="../../dcommon/images/contents.png" alt="Go To Table Of Contents" border="0" height="16" width="16" /><br /> |
| </td><td> </td><td align="center"><a href="../../" target="_top" class="external text" title="Search" rel="nofollow"><img src="../../dcommon/images/search.png" alt="Search" style="border:0;" /><br /><span class="mini"></span></a></td><td> </td><td align="center"><a href="../eclipselink_moxy.pdf" title="PDF" target="_blank"><img src="../../dcommon/images/pdf_icon.png" style="padding-right:5px;border:0" alt="PDF"></a></td> |
| </tr> |
| </table> |
| </td> |
| </tr> |
| </table> |
| </div> |
| <!-- class="footer" --> |
| <div id="copyright">Copyright © 2014 by The Eclipse Foundation under the <a href="http://www.eclipse.org/org/documents/epl-v10.php">Eclipse Public License (EPL)</a><br /> <script type="text/javascript">var LastUpdated = document.lastModified;document.writeln ("Updated: " + LastUpdated);</script> </div><!-- START: Analytics --><script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-1608008-2']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script><!-- END: Analytics --><!-- START: Sharethis --><script>var options={ "publisher": "e2fe9e07-fab6-4f84-83ea-0991b429842c", "position": "right", "ad": { "visible": false, "openDelay": 5, "closeDelay": 0}};var st_hover_widget = new sharethis.widgets.hoverbuttons(options);</script><!-- END: Sharethis --></body> |
| </html> |