Jump to: navigation, search

Difference between revisions of "EclipseLink/Examples/DBWS/DBWSIntermediateIgnoreColumn"

(New page: pending)
 
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
pending
+
<css>
 +
  .source-java5 {padding:4px;border:1px solid black; background-color: white;}
 +
  .source-xml {padding:4px;border:1px solid black; background-color: white;}
 +
  .source-text {padding:4px;border:1px solid black; background-color: white;}
 +
</css>
 +
__NOTOC__
 +
 
 +
== Skip a database column so that is does not show up in generated schema ==
 +
As seen in the previous [[../DBWSIntermediateAttribute|Intermediate example]],  a user can provide a custom <code>NamingConventionTransformer</code>.
 +
The following <code>NamingConventionTransformer</code> will:
 +
* name the schema element '<tt>simple</tt>'
 +
* make the element names lowercase
 +
* skip the <tt>SINCE</tt> field
 +
<source lang=java5>
 +
package foo.bar.blah;
 +
 
 +
import org.eclipse.persistence.tools.dbws.DefaultNamingConventionTransformer;
 +
import static org.eclipse.persistence.tools.dbws.NamingConventionTransformer.ElementStyle.ELEMENT;
 +
import static org.eclipse.persistence.tools.dbws.NamingConventionTransformer.ElementStyle.NONE;
 +
 
 +
public class MyNamingConventionTransformer extends DefaultNamingConventionTransformer {
 +
 
 +
    @Override
 +
    public String generateSchemaAlias(String tableName) {
 +
        return super.generateSchemaAlias("simple");
 +
    }
 +
 
 +
    @Override
 +
    public String generateElementAlias(String originalElementName) {
 +
        return super.generateElementAlias(originalElementName.toLowerCase());
 +
    }
 +
 
 +
    @Override
 +
    public ElementStyle styleForElement(String elementName) {
 +
        if ("since".equalsIgnoreCase(elementName)) {
 +
            return NONE;
 +
        }
 +
        return ELEMENT;
 +
    }
 +
}
 +
</source>
 +
[[Category:EclipseLink/Example/DBWS]]

Latest revision as of 10:06, 7 October 2010


Skip a database column so that is does not show up in generated schema

As seen in the previous Intermediate example, a user can provide a custom NamingConventionTransformer. The following NamingConventionTransformer will:

  • name the schema element 'simple'
  • make the element names lowercase
  • skip the SINCE field
package foo.bar.blah;
 
import org.eclipse.persistence.tools.dbws.DefaultNamingConventionTransformer;
import static org.eclipse.persistence.tools.dbws.NamingConventionTransformer.ElementStyle.ELEMENT;
import static org.eclipse.persistence.tools.dbws.NamingConventionTransformer.ElementStyle.NONE;
 
public class MyNamingConventionTransformer extends DefaultNamingConventionTransformer {
 
    @Override
    public String generateSchemaAlias(String tableName) {
        return super.generateSchemaAlias("simple");
    }
 
    @Override
    public String generateElementAlias(String originalElementName) {
        return super.generateElementAlias(originalElementName.toLowerCase());
    }
 
    @Override
    public ElementStyle styleForElement(String elementName) {
        if ("since".equalsIgnoreCase(elementName)) {
            return NONE;
        }
        return ELEMENT;
    }
}