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/DBWS/Creating EclipseLink DBWS Services (ELUG)"

m
(reorganized the page a little; edited cross-refs)
Line 1: Line 1:
 
<b>Note: A basic overview of EclipseLink Database Web Services (DBWS) can be found</b> [[EclipseLink/FAQ/WhatIsDBWS|here]]
 
<b>Note: A basic overview of EclipseLink Database Web Services (DBWS) can be found</b> [[EclipseLink/FAQ/WhatIsDBWS|here]]
 
__TOC__
 
__TOC__
 +
  
 
==Creating EclipseLink DBWS Services==
 
==Creating EclipseLink DBWS Services==
This section describes how to automatically generate a <tt>.war</tt> file containing the EclipseLink DBWS service descriptor along with all required deployment artifacts for a JAX-WS 2.0 Web service (WSDL, XML schema, web.xml, EclipseLink ORM and OXM native Project XML files, etc.)
+
You can generate a WAR file containing the EclipseLink DBWS service descriptor along with all required deployment artifacts for a JAX-WS 2.0 Web service (WSDL, XML schema, <tt>web.xml</tt>, EclipseLink object-relational mapping (ORM) and object-XML mapping (OXM) native project XML files, and so on).
 +
 
 
<onlyinclude>
 
<onlyinclude>
 
<source lang="text" enclose="div">
 
<source lang="text" enclose="div">
Line 32: Line 34:
 
             swaref.xsd                                 
 
             swaref.xsd                                 
 
</source>
 
</source>
 +
 
{| class="RuleFormalWideMax" dir="ltr" title="<b>EclipseLink DBWS Service <code>.war</code> File Contents</b>" width="100%" border="1" frame="border" rules="all" cellpadding="3" frame="border" rules="all"
 
{| class="RuleFormalWideMax" dir="ltr" title="<b>EclipseLink DBWS Service <code>.war</code> File Contents</b>" width="100%" border="1" frame="border" rules="all" cellpadding="3" frame="border" rules="all"
 
|+ <b>EclipseLink DBWS Service <code>.war</code> File Contents</b>
 
|+ <b>EclipseLink DBWS Service <code>.war</code> File Contents</b>
Line 41: Line 44:
 
|-
 
|-
 
|<tt>web.xml</tt>
 
|<tt>web.xml</tt>
|The Web application deployment file (required for deployment as a JAX-WS Web service)
+
|The Web application deployment file (required for deployment as a JAX-WS Web service).
 
|-
 
|-
 
|<tt>eclipselink-dbws.xml</tt>
 
|<tt>eclipselink-dbws.xml</tt>
|[[EclipseLink/UserGuide/DBWS/Overview/EclipseLink_DBWS_Service_Descriptor_File_(ELUG)|The EclipseLink DBWS service descriptor file]]<br/>(described in full in the User Guide)
+
|[[EclipseLink/UserGuide/DBWS/Overview/EclipseLink_DBWS_Service_Descriptor_File_(ELUG)|The EclipseLink DBWS service descriptor file]]<br/>(described in full in the EclipseLink User Guide).
 
|-
 
|-
 
|<tt>eclipselink-dbws-or.xml</tt>
 
|<tt>eclipselink-dbws-or.xml</tt>
|The EclipseLink ORM Project XML file.<br/>For more information, see [[Introduction to Relational Projects (ELUG)]]
+
|The EclipseLink ORM project XML file.<br/>For more information, see [[Introduction to Relational Projects (ELUG)]].
 
|-
 
|-
 
|<tt>eclipselink-dbws-ox.xml</tt>
 
|<tt>eclipselink-dbws-ox.xml</tt>
|The EclipseLink OXM Project XML file.<br/>For more information, see [[Introduction to XML Projects (ELUG)]]
+
|The EclipseLink OXM project XML file.<br/>For more information, see [[Introduction to XML Projects (ELUG)]].
 
|-
 
|-
 
|<tt>eclipselink-dbws-sessions.xml</tt>
 
|<tt>eclipselink-dbws-sessions.xml</tt>
|The EclipseLink sessions.xml file for the EclipseLink DBWS service.<br/>It contains references to the EclipseLink ORM and OXM Project XML files.<br/>For more information, see [[Introduction to EclipseLink Sessions (ELUG)]]
+
|The EclipseLink sessions.xml file for the EclipseLink DBWS service.<br/>It contains references to the EclipseLink ORM and OXM project XML files.<br/>For more information, see [[Introduction to EclipseLink Sessions (ELUG)]].
 
|-
 
|-
 
|<tt>eclipselink-dbws-schema.xsd</tt>
 
|<tt>eclipselink-dbws-schema.xsd</tt>
|Contains XML type definitions for operation arguments and return types.<br/>The <tt>DBWSBuilder</tt> utility automatically generates this file from database<br/>metadata to derive element-tag names and types
+
|Contains XML type definitions for operation arguments and return types.<br/>The <tt>DBWSBuilder</tt> utility automatically generates this file from database<br/>metadata to derive element-tag names and types.
 
|-
 
|-
 
|<tt>eclipselink-dbws.wsdl</tt>
 
|<tt>eclipselink-dbws.wsdl</tt>
|Contains entries for all operations in the EclipseLink DBWS service.<br/>required for deployment as a JAX-WS Web service
+
|Contains entries for all operations in the EclipseLink DBWS service.<br/>required for deployment as a JAX-WS Web service.
 
|-
 
|-
 
|<tt>swaref.xsd</tt>
 
|<tt>swaref.xsd</tt>
|(optional) Contains XML type definitions for SOAP attachments
+
|(optional) Contains XML type definitions for SOAP attachments.
 
|-
 
|-
 
|}
 
|}
NB - the files <tt>swaref.xsd</tt> and <tt>web.xml</tt> have names and content determined by their roles in web deployment and cannot be changed.
+
 
 +
Note that the files <tt>swaref.xsd</tt> and <tt>web.xml</tt> have names and content determined by their roles in Web deployment and cannot be changed.
 
</onlyinclude>
 
</onlyinclude>
 
The deployable <tt>.war</tt> file has been verified to work with the [http://www.oracle.com/technology/software/products/ias/htdocs/wls_main.html?rssid=rss_otn_soft Oracle WebLogic Server 10.3 JavaEE container].
 
The deployable <tt>.war</tt> file has been verified to work with the [http://www.oracle.com/technology/software/products/ias/htdocs/wls_main.html?rssid=rss_otn_soft Oracle WebLogic Server 10.3 JavaEE container].
  
An alternate deployable <tt>.jar</tt> file has been verified to work as a JavaSE 6 'container-less' [http://java.sun.com/javase/6/docs/api/javax/xml/ws/Endpoint.html EndPoint] (please see <br /> the example <i>[[EclipseLink/Examples/DBWS/AdvancedJavase6Containerless|EclipseLink DBWS Service deployed as a JavaSE 6 'containerless' EndPoint]]</i> for more details).
+
An alternate deployable JAR file has been verified to work as a JavaSE 6 'container-less' [http://java.sun.com/javase/6/docs/api/javax/xml/ws/Endpoint.html EndPoint] (see <br /> the example <i>[[EclipseLink/Examples/DBWS/AdvancedJavase6Containerless|EclipseLink DBWS Service deployed as a JavaSE 6 'containerless' EndPoint]]</i> for details).
  
This section describes the following:
+
This section describes [[#How to Create EclipseLink DBWS Services Using the DBWSBuilder Utility|how to create EclipseLink DBWS services using the <tt>DBWSBuilder</tt> utility]].
*[[#How to Create EclipseLink DBWS Services Using the DBWSBuilder utility|How to Create EclipseLink DBWS Services Using the <tt>DBWSBuilder</tt> utility]]
+
*[[#How to Customize an EclipseLink DBWS Service|How to Customize an EclipseLink DBWS Service]]
+
*[[#How to Use DBWSBuilder an an API|How to Use <tt>DBWSBuilder</tt> an an API]]
+
  
===Creating EclipseLink DBWS Services Using the <tt>DBWSBuilder</tt> utility===
+
 
 +
===How to Create EclipseLink DBWS Services Using the DBWSBuilder Utility===
 
You can use the EclipseLink DBWS design-time utility <tt>DBWSBuilder</tt> to create deployment files. <tt>DBWSBuilder</tt> is a Java application that processes the operations described in an [[EclipseLink dbws-builder.xml File (ELUG)#eclipselink-dbws-builder.xml|EclipseLink DBWS builder XML file]] to produce all the required deployment artifacts.  
 
You can use the EclipseLink DBWS design-time utility <tt>DBWSBuilder</tt> to create deployment files. <tt>DBWSBuilder</tt> is a Java application that processes the operations described in an [[EclipseLink dbws-builder.xml File (ELUG)#eclipselink-dbws-builder.xml|EclipseLink DBWS builder XML file]] to produce all the required deployment artifacts.  
  
Line 82: Line 84:
 
*$JAVA_HOME
 
*$JAVA_HOME
 
*$DRIVER_CLASSPATH  
 
*$DRIVER_CLASSPATH  
There are script files provided for invoking <tt>DBWSBuilder</tt>. They are located in <tt><ECLIPSELINK_HOME>\utils\dbws</tt>. The scripts are '''dbwsbuilder.cmd''' for Windows usage and '''dbwsbuilder.sh''' for other operating systems.
+
 
 +
There are script files provided for invoking <tt>DBWSBuilder</tt>. They are located in <tt><ECLIPSELINK_HOME>\utils\dbws</tt>. The scripts are '''dbwsbuilder.cmd''' for Windows usage, and '''dbwsbuilder.sh''' for other operating systems.
 +
 
 
<source lang="text">
 
<source lang="text">
 
DBWSBuilder usage - [] indicates optional argument:
 
DBWSBuilder usage - [] indicates optional argument:
Line 92: Line 96:
  
 
Using <tt>DBWSBuilder</tt>, you can generate an EclipseLink DBWS service from the following sources:  
 
Using <tt>DBWSBuilder</tt>, you can generate an EclipseLink DBWS service from the following sources:  
*an existing relational database table;  
+
* [[#Creating an EclipseLink DBWS Service from a Database Table|an existing relational database table]];
*one or more SQL <tt>SELECT</tt> statements;  
+
* [[#Creating an EclipseLink DBWS Service from a SQL Statement|one or more SQL <tt>SELECT</tt> statements]];
*a stored procedure.
+
* [[#Creating an EclipseLink DBWS Service from a Stored Procedure|a stored procedure]].
 +
 
  
 
====Creating an EclipseLink DBWS Service from a Database Table====
 
====Creating an EclipseLink DBWS Service from a Database Table====
Create an EclipseLink DBWS builder XML File with a <tt>&lt;table&gt;</tt> <b>query operation</b>:
+
Create an EclipseLink DBWS builder XML file with a <tt>&lt;table&gt;</tt> <b>query operation</b>:
 +
 
 
<source lang="xml" enclose="div">
 
<source lang="xml" enclose="div">
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?xml version="1.0" encoding="UTF-8"?>
Line 111: Line 117:
 
</dbws-builder>
 
</dbws-builder>
 
</source>
 
</source>
 +
 
For more information, see the basic example [[EclipseLink/Examples/DBWS/DBWSBasicTable| Creating EclipseLink DBWS Service based on Database Table]].
 
For more information, see the basic example [[EclipseLink/Examples/DBWS/DBWSBasicTable| Creating EclipseLink DBWS Service based on Database Table]].
  
====Creating an EclipseLink DBWS Service from a SQL statement====
+
 
Create an EclipseLink DBWS builder XML File with a <tt>&lt;sql&gt;</tt> <b>query operation</b>:
+
====Creating an EclipseLink DBWS Service from a SQL Statement====
 +
Create an EclipseLink DBWS builder XML file with a <tt>&lt;sql&gt;</tt> <b>query operation</b>:
 +
 
 
<source lang="xml" enclose="div">
 
<source lang="xml" enclose="div">
 
<?xml version="1.0" encoding="UTF-8"?>  
 
<?xml version="1.0" encoding="UTF-8"?>  
Line 129: Line 138:
 
</dbws-builder>
 
</dbws-builder>
 
</source>
 
</source>
 +
 +
 
=====Parameter Binding=====
 
=====Parameter Binding=====
 
The SQL <tt>SELECT</tt> statement for a <tt>&lt;sql&gt;</tt> operation may have parameters that must be bound to a datatype from the <b><tt>eclipselink-dbws-schema.xsd</tt></b>, or to any of the basic XSD datatypes. The SQL <tt>SELECT</tt> string uses JDBC-style '?' markers to indicate the position of the argument. The <tt>&lt;sql&gt;</tt> operation uses nested <tt>&lt;binding&gt;</tt> elements to match the datatype to the parameters. The order in which <tt>&lt;binding&gt;</tt> elements are defined must match the order of '?' markers in the SQL string:
 
The SQL <tt>SELECT</tt> statement for a <tt>&lt;sql&gt;</tt> operation may have parameters that must be bound to a datatype from the <b><tt>eclipselink-dbws-schema.xsd</tt></b>, or to any of the basic XSD datatypes. The SQL <tt>SELECT</tt> string uses JDBC-style '?' markers to indicate the position of the argument. The <tt>&lt;sql&gt;</tt> operation uses nested <tt>&lt;binding&gt;</tt> elements to match the datatype to the parameters. The order in which <tt>&lt;binding&gt;</tt> elements are defined must match the order of '?' markers in the SQL string:
 +
 
<source lang="xml" enclose="div">
 
<source lang="xml" enclose="div">
 
<?xml version="1.0" encoding="UTF-8"?>  
 
<?xml version="1.0" encoding="UTF-8"?>  
Line 147: Line 159:
 
</dbws-builder>
 
</dbws-builder>
 
</source>
 
</source>
The argument named <tt>"EMPNO"</tt> is bound to an integer type while the argument named <tt>"LAST_NAME"</tt> is bound to a string type.
+
 
 +
The argument named <tt>"EMPNO"</tt> is bound to an integer type, while the argument named <tt>"LAST_NAME"</tt> is bound to a string type.
 
<br />
 
<br />
 
For more information, see the basic example [[EclipseLink/Examples/DBWS/DBWSBasicSQL|Creating EclipseLink DBWS Service based on Results Sets from custom SQL <code>SELECT</code> statements]].
 
For more information, see the basic example [[EclipseLink/Examples/DBWS/DBWSBasicSQL|Creating EclipseLink DBWS Service based on Results Sets from custom SQL <code>SELECT</code> statements]].
 +
  
 
====Creating an EclipseLink DBWS Service from a Stored Procedure====
 
====Creating an EclipseLink DBWS Service from a Stored Procedure====
 
Create an EclipseLink DBWS builder XML File with a <tt>&lt;procedure&gt;</tt> <b>query operation</b>:
 
Create an EclipseLink DBWS builder XML File with a <tt>&lt;procedure&gt;</tt> <b>query operation</b>:
 +
 
<source lang="xml" enclose="div">
 
<source lang="xml" enclose="div">
 
<?xml version="1.0" encoding="UTF-8"?>  
 
<?xml version="1.0" encoding="UTF-8"?>  
Line 168: Line 183:
 
</dbws-builder>  
 
</dbws-builder>  
 
</source>
 
</source>
 +
 
For more information, see the basic example [[EclipseLink/Examples/DBWS/DBWSBasicStoredProcedure|Creating EclipseLink DBWS Service based on Stored Procedure]].
 
For more information, see the basic example [[EclipseLink/Examples/DBWS/DBWSBasicStoredProcedure|Creating EclipseLink DBWS Service based on Stored Procedure]].
 +
 +
  
 
==Customizing an EclipseLink DBWS Service==
 
==Customizing an EclipseLink DBWS Service==
There are a number use-cases that require an EclipseLink DBWS Service to be customized. The use-cases can be sub-divided into
+
There are a number use-cases that require an EclipseLink DBWS Service to be customized. The use-cases can be subdivided into the following categories:
* simple - changing an &lt;element-tag&gt; to an "attribute"
+
* [[#How to Perform Simple Customization|simple]] - changing an &lt;element-tag&gt; to an "attribute";
* intermediate - customizing the EclipseLink ORM or OXM Projects
+
* [[#How to Perform Intermediate Customization|intermediate ]] - customizing the EclipseLink ORM or OXM Projects;
* advanced - hand-generating all required deployment artifacts
+
* [[#How to Perform Advanced Customization|advanced]] - manually generating all required deployment artifacts.
 +
 
 +
 
 +
===How to Perform Simple Customization===
 +
See the example [[EclipseLink/Examples/DBWS/DBWSIntermediateAttribute|Changing an &lt;element-tag&gt; to an "attribute"]].
  
===Simple customization===
 
See the example [[EclipseLink/Examples/DBWS/DBWSIntermediateAttribute|Changing an &lt;element-tag&gt; to an "attribute"]]
 
  
===Intermediate customization===
+
===How to Perform Intermediate Customization===
The primary reason to use an EclipseLink SessionCustomizer is to enable programmatic access to the EclipseLink API. Using this API, one can retrieve the ORM or OXM descriptors from the session, and from these descriptors add, change or delete mappings. Other examples might be to
+
The primary reason to use an EclipseLink SessionCustomizer is to enable programmatic access to the EclipseLink API. Using this API, you can retrieve the object-relational (ORM) or object-XML mapping (OXM) descriptors from the session, and from these descriptors add, change or delete mappings. You could also consider turning off the session cache, or changing the transaction isolation level of the database connection, as the following example shows:
turn off the session cache or change the transation isolation level of the database connection:
+
  
 
Implement a <code><b>org.eclipse.persistence.config.SessionCustomizer</b></code>:
 
Implement a <code><b>org.eclipse.persistence.config.SessionCustomizer</b></code>:
Line 202: Line 221:
 
}
 
}
 
</source>
 
</source>
In the <tt>DBWSBuilder</tt> builder XML file, specify if the customization applies to the ORM Project or the OXM Project:
+
 
 +
In the <tt>DBWSBuilder</tt> builder XML file, specify if the customization applies to the ORM project or the OXM project:
 +
 
 
<source lang="xml" enclose="div">
 
<source lang="xml" enclose="div">
 
<?xml version="1.0" encoding="UTF-8"?>  
 
<?xml version="1.0" encoding="UTF-8"?>  
Line 220: Line 241:
 
     <property name="oxSessionCustomizerClassName">some.java.package.MyOXSessionCustomizer</property>  
 
     <property name="oxSessionCustomizerClassName">some.java.package.MyOXSessionCustomizer</property>  
 
</source>
 
</source>
For more details, please see the [[Introduction to EclipseLink Sessions (ELUG)#Session_Customization|Session Customization section]] in the User Guide.
 
  
===Advanced customization===
+
For details, see [[Introduction to EclipseLink Sessions (ELUG)#Session_Customization|Session Customization]].
You can customize an EclipseLink DBWS service by creating your own '''project.xml''' and '''sessions.xml''' files.  
+
 
Using your preferred utility you can map your objects to your relational database in an EclipseLink relational project, map your objects to your XML schema in an EclipseLink XML project, and create an EclipseLink sessions.xml file that references both projects.  
+
 
 +
===How to Perform Advanced Customization===
 +
You can customize an EclipseLink DBWS service by creating your own <tt>project.xml</tt> and <tt>sessions.xml</tt> files.  
 +
Using your preferred utility, you can do the following:
 +
* map your objects to your relational database in an EclipseLink relational project;
 +
* map your objects to your XML schema in an EclipseLink XML project:
 +
* create an EclipseLink <tt>sessions.xml</tt> file that references both projects.  
 +
 
 
In this way, you can control all aspects of the relational and XML mapping. This approach is best when you want to customize most or all details. See the advanced example [[EclipseLink/Examples/DBWS/ExistingMappingFiles|Creating EclipseLink DBWS Service based upon existing ORM and OXM Projects]].
 
In this way, you can control all aspects of the relational and XML mapping. This approach is best when you want to customize most or all details. See the advanced example [[EclipseLink/Examples/DBWS/ExistingMappingFiles|Creating EclipseLink DBWS Service based upon existing ORM and OXM Projects]].
  
==DBWSBuilder API==
 
The EclipseLink DBWS design-time utility, <tt>DBWSBuilder</tt>, is a Java application that generates EclipseLink DBWS files and assembles them into deployable archives. One can also set the <tt>DBWSBuilder</tt>’s properties, add table or procedure definitions and SQL operations programmatically through <tt>DBWSBuilder</tt>’s API.
 
  
More info pending
+
 
 +
==Using DBWSBuilder API==
 +
The EclipseLink DBWS design-time utility, <tt>DBWSBuilder</tt>, is a Java application that generates EclipseLink DBWS files and assembles them into deployable archives. YOu can also set the <tt>DBWSBuilder</tt>’s properties, add table or procedure definitions and SQL operations programmatically through <tt>DBWSBuilder</tt>’s API.
 +
 
 +
Information pending
  
 
----
 
----

Revision as of 11:00, 6 April 2009

Note: A basic overview of EclipseLink Database Web Services (DBWS) can be found here


Creating EclipseLink DBWS Services

You can generate a WAR file containing the EclipseLink DBWS service descriptor along with all required deployment artifacts for a JAX-WS 2.0 Web service (WSDL, XML schema, web.xml, EclipseLink object-relational mapping (ORM) and object-XML mapping (OXM) native project XML files, and so on).


 root of war file
    \---web-inf
    |
    |   web.xml
    |
    +---classes
    |   +---foo                               -- optional domain classes (typically not required)
    |   |   \---bar                              
    |   |           Address.class
    |   |           Employee.class
    |   |           PhoneNumber.class
    |   |
    |   +---META-INF
    |   |       eclipselink-dbws.xml
    |   |       eclipselink-dbws-or.xml
    |   |       eclipselink-dbws-ox.xml
    |   |       eclipselink-dbws-sessions.xml -- name can be overridden by <sessions-file> entry in eclipselink-dbws.xml
    |   |
    |   \---_dbws
    |           DBWSProvider.class            -- auto-generated JAX-WS 2.0 Provider
    |
    \---wsdl
            eclipselink-dbws-schema.xsd
            eclipselink-dbws.wsdl
            swaref.xsd
EclipseLink DBWS Service .war File Contents
File Description
web.xml The Web application deployment file (required for deployment as a JAX-WS Web service).
eclipselink-dbws.xml The EclipseLink DBWS service descriptor file
(described in full in the EclipseLink User Guide).
eclipselink-dbws-or.xml The EclipseLink ORM project XML file.
For more information, see Introduction to Relational Projects (ELUG).
eclipselink-dbws-ox.xml The EclipseLink OXM project XML file.
For more information, see Introduction to XML Projects (ELUG).
eclipselink-dbws-sessions.xml The EclipseLink sessions.xml file for the EclipseLink DBWS service.
It contains references to the EclipseLink ORM and OXM project XML files.
For more information, see Introduction to EclipseLink Sessions (ELUG).
eclipselink-dbws-schema.xsd Contains XML type definitions for operation arguments and return types.
The DBWSBuilder utility automatically generates this file from database
metadata to derive element-tag names and types.
eclipselink-dbws.wsdl Contains entries for all operations in the EclipseLink DBWS service.
required for deployment as a JAX-WS Web service.
swaref.xsd (optional) Contains XML type definitions for SOAP attachments.

Note that the files swaref.xsd and web.xml have names and content determined by their roles in Web deployment and cannot be changed.

The deployable .war file has been verified to work with the Oracle WebLogic Server 10.3 JavaEE container.

An alternate deployable JAR file has been verified to work as a JavaSE 6 'container-less' EndPoint (see
the example EclipseLink DBWS Service deployed as a JavaSE 6 'containerless' EndPoint for details).

This section describes how to create EclipseLink DBWS services using the DBWSBuilder utility.


How to Create EclipseLink DBWS Services Using the DBWSBuilder Utility

You can use the EclipseLink DBWS design-time utility DBWSBuilder to create deployment files. DBWSBuilder is a Java application that processes the operations described in an EclipseLink DBWS builder XML file to produce all the required deployment artifacts.

Be sure to set the following environment variables in the <ECLIPSELINK_HOME>\utils\dbws\setenv.cmd (or setenv.sh file) before invoking DBWSBuilder:

  • $JAVA_HOME
  • $DRIVER_CLASSPATH

There are script files provided for invoking DBWSBuilder. They are located in <ECLIPSELINK_HOME>\utils\dbws. The scripts are dbwsbuilder.cmd for Windows usage, and dbwsbuilder.sh for other operating systems.

DBWSBuilder usage - [] indicates optional argument:
prompt > dbwsbuilder.cmd -builderFile {path_to_builder.xml} -stageDir {path_to_stageDir} -packageAs[:archive_flag] {packager} [additional args]
Available packagers:
  -packageAs:[default=archive] javase [jarFilename]
  -packageAs:[default=archive] wls [warFilename]

Using DBWSBuilder, you can generate an EclipseLink DBWS service from the following sources:


Creating an EclipseLink DBWS Service from a Database Table

Create an EclipseLink DBWS builder XML file with a <table> query operation:

<?xml version="1.0" encoding="UTF-8"?>
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <properties>
    <property name="projectName">table_test</property>
    ... database properties ...
  </properties>
  <table
   schemaPattern="%"
   tableNamePattern="dbws_crud"
 />
</dbws-builder>

For more information, see the basic example Creating EclipseLink DBWS Service based on Database Table.


Creating an EclipseLink DBWS Service from a SQL Statement

Create an EclipseLink DBWS builder XML file with a <sql> query operation:

<?xml version="1.0" encoding="UTF-8"?>
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 <properties>
    <property name="projectName">sql_test</property>
    ... database properties ...
  </properties>
  <sql name="employeeInfo" simpleXMLFormatTag="employee-info" xmlTag="aggregate-counts">
    <text>
      <![CDATA[select count(*) as "COUNT", max(SAL) as "MAX-Salary" from EMP]]>
    </text>
  </sql>
</dbws-builder>


Parameter Binding

The SQL SELECT statement for a <sql> operation may have parameters that must be bound to a datatype from the eclipselink-dbws-schema.xsd, or to any of the basic XSD datatypes. The SQL SELECT string uses JDBC-style '?' markers to indicate the position of the argument. The <sql> operation uses nested <binding> elements to match the datatype to the parameters. The order in which <binding> elements are defined must match the order of '?' markers in the SQL string:

<?xml version="1.0" encoding="UTF-8"?>
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 <properties>
    <property name="projectName">sql_binding_test</property>
    ... database properties ...
  </properties>
  <sql name="findEmpByName" isCollection="true" isSimpleXMLFormat="true">  
    <text>
      <![CDATA[select * from EMP where EMPNO = ? and LAST_NAME = ?]]>
    </text>
    <binding name="EMPNO" type="xsd:int"/>
    <binding name="LAST_NAME" type="xsd:string"/>
  </sql>
</dbws-builder>

The argument named "EMPNO" is bound to an integer type, while the argument named "LAST_NAME" is bound to a string type.
For more information, see the basic example Creating EclipseLink DBWS Service based on Results Sets from custom SQL SELECT statements.


Creating an EclipseLink DBWS Service from a Stored Procedure

Create an EclipseLink DBWS builder XML File with a <procedure> query operation:

<?xml version="1.0" encoding="UTF-8"?>
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 <properties>
    <property name="projectName">procedure_test</property>
    ... database properties ...
    </properties>
  <procedure
   returnType="empType"
   catalogPattern="SOME_PKG"
   schemaPattern="SCOTT"
   procedurePattern="GetEmployeeByEMPNO_DEPTNO"/>
  </procedure>
</dbws-builder>

For more information, see the basic example Creating EclipseLink DBWS Service based on Stored Procedure.


Customizing an EclipseLink DBWS Service

There are a number use-cases that require an EclipseLink DBWS Service to be customized. The use-cases can be subdivided into the following categories:

  • simple - changing an <element-tag> to an "attribute";
  • intermediate - customizing the EclipseLink ORM or OXM Projects;
  • advanced - manually generating all required deployment artifacts.


How to Perform Simple Customization

See the example Changing an <element-tag> to an "attribute".


How to Perform Intermediate Customization

The primary reason to use an EclipseLink SessionCustomizer is to enable programmatic access to the EclipseLink API. Using this API, you can retrieve the object-relational (ORM) or object-XML mapping (OXM) descriptors from the session, and from these descriptors add, change or delete mappings. You could also consider turning off the session cache, or changing the transaction isolation level of the database connection, as the following example shows:

Implement a org.eclipse.persistence.config.SessionCustomizer:

package some.java.package;

import org.eclipse.persistence.config.SessionCustomizer;
import org.eclipse.persistence.sessions.Session;
import org.eclipse.persistence.sessions.DatabaseLogin;

public class MySessionCustomizer implements SessionCustomizer {

  public MySessionCustomizer() {
  }

  public void customize(Sesssion session) {
    DatabaseLogin login = (DatabaseLogin)session.getDatasourceLogin();
    login.setTransactionIsolation(DatabaseLogin.TRANSACTION_READ_UNCOMMITTED);
  }
}

In the DBWSBuilder builder XML file, specify if the customization applies to the ORM project or the OXM project:

<?xml version="1.0" encoding="UTF-8"?>
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 <properties>
    <property name="projectName">customize_test</property>
     ...
    <property name="orSessionCustomizerClassName">some.java.package.MyORSessionCustomizer</property>

or

<?xml version="1.0" encoding="UTF-8"?>
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 <properties>
    <property name="projectName">customize_test</property>
     ...
    <property name="oxSessionCustomizerClassName">some.java.package.MyOXSessionCustomizer</property>

For details, see Session Customization.


How to Perform Advanced Customization

You can customize an EclipseLink DBWS service by creating your own project.xml and sessions.xml files. Using your preferred utility, you can do the following:

  • map your objects to your relational database in an EclipseLink relational project;
  • map your objects to your XML schema in an EclipseLink XML project:
  • create an EclipseLink sessions.xml file that references both projects.

In this way, you can control all aspects of the relational and XML mapping. This approach is best when you want to customize most or all details. See the advanced example Creating EclipseLink DBWS Service based upon existing ORM and OXM Projects.


Using DBWSBuilder API

The EclipseLink DBWS design-time utility, DBWSBuilder, is a Java application that generates EclipseLink DBWS files and assembles them into deployable archives. YOu can also set the DBWSBuilder’s properties, add table or procedure definitions and SQL operations programmatically through DBWSBuilder’s API.

Information pending


Copyright Statement

Copyright © Eclipse Foundation, Inc. All Rights Reserved.