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/DBWS/DBWSIntermediateAttribute"

Line 1: Line 1:
 +
<css>
 +
  .source-java {border-style: solid; background-color: white}
 +
</css>
 
== Naming Convention for schema elements ==
 
== Naming Convention for schema elements ==
 
As seen in the Basic Table example, the {{:EclipseLink/Examples/DBWS/DBWSBasicTable#gen_schema}}
 
As seen in the Basic Table example, the {{:EclipseLink/Examples/DBWS/DBWSBasicTable#gen_schema}}
 
Converting the database metadata into the names of <element-tag>'s is the job of <code>o.e.p.tools.dbws.NamingConventionTransformer</code>'s
 
Converting the database metadata into the names of <element-tag>'s is the job of <code>o.e.p.tools.dbws.NamingConventionTransformer</code>'s
<source lang="java5" enclose="div">
+
<source lang="java5">
 
public interface NamingConventionTransformer {
 
public interface NamingConventionTransformer {
  

Revision as of 13:14, 3 June 2009

Naming Convention for schema elements

As seen in the Basic Table example, the DBWSBuilder-generated eclipselink-dbws-schema.xsd file derives <element-tag> names from the Database table metadata:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 >
  <xsd:complexType name="empType">
    <xsd:sequence>
      <xsd:element name="empno" type="xsd:int" xsi:nil="false"/>
      <xsd:element name="ename" type="xsd:string" xsi:nil="true"/>
      <xsd:element name="job" type="xsd:string" xsi:nil="true"/>
      <xsd:element name="mgr" type="xsd:int" minOccurs="0" xsi:nil="true"/>
      <xsd:element name="hiredate" type="xsd:dateTime" xsi:nil="true"/>
      <xsd:element name="sal" type="xsd:decimal" xsi:nil="true"/>
      <xsd:element name="comm" type="xsd:int" minOccurs="0" xsi:nil="true"/>
      <xsd:element name="deptno" type="xsd:int" xsi:nil="true"/>
    </xsd:sequence>
  </xsd:complexType>
</xsd:schema>

Converting the database metadata into the names of <element-tag>'s is the job of o.e.p.tools.dbws.NamingConventionTransformer's

public interface NamingConventionTransformer {
 
    public enum ElementStyle {
        ELEMENT, ATTRIBUTE, NONE
    };
 
    public String generateSchemaName(String tableName);
 
    public String generateElementAlias(String originalElementName);
 
    public ElementStyle styleForElement(String originalElementName);
}

In the eclipselink-dbwsutils.jar, there are built-in transformers that form a Chain-of-Responsibility

NCTChainOfResponsibility.png

In the o.e.p.tools.dbws.NamingConventionTransformer services file, the transformer chain is listed in order:

eclipselink-dbwsutils.jar
|  
+---META-INF
|   |   MANIFEST.MF
|   |  
|   \---services
|           org.eclipse.persistence.tools.dbws.NamingConventionTransformer
            contains 3 lines:
              org.eclipse.persistence.tools.dbws.ToLowerTransformer
              org.eclipse.persistence.tools.dbws.TypeSuffixTransformer
              org.eclipse.persistence.tools.dbws.SQLX2003Transformer

=== Changing an <element-tag> to an "attrib It is possible to change an <element-tag> to an "attribute" with a custom transformer:

Back to the top