Disclaimer: I am the author of Hyperjaxb3.
Entity name is not customizable, but you can implement your own naming strategy to generate fully qualified entity names.
For this, you'd have to impement the org.jvnet.hyperjaxb3.ejb.strategy.naming.Naming
interface. The easiest would be to subclass org.jvnet.hyperjaxb3.ejb.strategy.naming.impl.DefaultNaming
and to override the getEntityName
method:
public String getEntityName(Mapping context, Outline outline, NType type) {
final JType theType = type.toType(outline, Aspect.EXPOSED);
assert theType instanceof JClass;
final JClass theClass = (JClass) theType;
return CodeModelUtils.getPackagedClassName(theClass);
}
You'll also have to include the org\jvnet\hyperjaxb3\ejb\plugin\custom\applicationContext.xml
resource to configure your custom naming strategy:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean name="naming" class="com.acme.foo.CustomNaming">
<property name="reservedNames" ref="reservedNames"/>
</bean>
</beans>
Finally, compile it all, pack as JAR and add to the HJ3 classpath, for instance via plugin dependencies in the Maven POM:
<plugin>
<groupId>org.jvnet.hyperjaxb3</groupId>
<artifactId>maven-hyperjaxb3-plugin</artifactId>
<configuration>...</configuration>
<dependencies>
<dependency>
<groupId>com.acme.foo</groupId>
<artifactId>hyperjaxb3-custom-naming-extension</artifactId>
<version>...</version>
</dependency>
</dependencies>
</plugin>
Here's a test project which implements/configures a custom naming stratgy:
See also: