We have a significant code base that utilizes Hyperjaxb3 to annotate Java classes that are generated using xjc (along with other xjc plugins, including one that is home-grown).
We are in the process of trying to upgrade from Hyperjaxb3 0.5.6 to 0.6.2, but have run into a significant issue with an apparent naming strategy change between these versions.
Specifically, where a complexType name like "OneTwo" results in a table name "ONETWO" in 0.5.6, whereas in 0.6.2 the table name is "ONE_TWO". Same for column names.
We have a very strong preference to NOT refactor hundreds of queries to accommodate such a naming change (although the newer, more traditional SQL naming certainly makes sense - we wish it had been the default behavior when this project started six years ago).
Is there an easy way to switch to the old naming strategy? Failing that, can you provide details on exactly how to extend Hyperjaxb3 with a custom naming strategy?
Having looked at this test or this one, it is not clear to us exactly what we need to do to our pom to specify a different naming strategy class, and the Extension Guide is currently empty.
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<configuration>
<extension>true</extension>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>${jaxb.commons.version}</version>
</plugin>
<plugin>
<groupId>org.jvnet.hyperjaxb3</groupId>
<artifactId>hyperjaxb3-ejb-plugin</artifactId>
<version>${hyperjaxb3.version}</version>
</plugin>
<plugin>
<groupId>${project.groupId}</groupId>
<artifactId>jaxb-x12</artifactId>
<version>${project.version}</version>
</plugin>
</plugins>
<args>
<arg>-enableIntrospection</arg>
<arg>-Xcopyable</arg>
<arg>-Xequals</arg>
<arg>-XhashCode</arg>
<arg>-Xinheritance</arg>
<arg>-Xhyperjaxb3-ejb</arg>
<arg>-Xx12</arg>
</args>
</configuration>
</plugin>
Author of HJ3 here.
Take a look at thes custom-naming test project. It implements and configures a custom naming strategy.
The solution consists of two parts: implementation of the naming strategy and configuration of this implementation.
You naming implementation must implement the
org.jvnet.hyperjaxb3.ejb.strategy.naming.Naming
interface. The easiest would be to inherit fromorg.jvnet.hyperjaxb3.ejb.strategy.naming.impl.DefaultNaming
.To configure you have to create a resource
/org/jvnet/hyperjaxb3/ejb/plugin/custom/applicationContext.xml
which is basically a Spring XML configuration. There, define a bean with the namenaming
:This will overwrite the standard naming strategy.