我已经建立了一个 maven 项目来从 xsd-Schema 生成 Java 类。首先,我配置了 maven-hyperjaxb3-plugin(参见下面的 pom.xml 片段),以便它可以将默认的 JPA2 注释放在实体中。其中一个注解是@java.persitence.Table(name = "table_name")。我想通过外部全局绑定扩展此注释,以便我也可以将模式名称放入其中。这样我就会得到@java.persitence.Table(name = "table_name", schema = "schema_name")。有没有办法做到这一点?在表名中全局添加前缀怎么样:@java.persitence.Table(name = "prefix_table_name"),有什么想法吗?
问候 Erzen
pom.xml 片段
<groupId>org.jvnet.hyperjaxb3</groupId>
<artifactId>maven-hyperjaxb3-plugin</artifactId>
<version>0.6.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<variant>jpa2</variant>
<extension>true</extension>
<roundtripTestClassName>EKMSEnvelopeRoundtripTest</roundtripTestClassName>
<args>
<arg>-Xinheritance</arg>
<arg>-XtoString</arg>
<arg>-Xannotate</arg>
</args>
<schemaExcludes>
<exclude>ekvaattributes.xsd</exclude>
</schemaExcludes>
</configuration>
bindings-xjc.xjb 片段
<jaxb:globalBindings localScoping="toplevel">
<!-- JPA-entities must be serializable -->
<xjc:serializable />
</jaxb:globalBindings>
<jaxb:bindings schemaLocation="schema.xsd"
node="/xs:schema">
<annox:annotate>
<!-- my attempt -->
<annox:annotate annox:class="javax.persistence.Table"
schema="schema_name">
</annox:annotate>
</annox:annotate>
<hj:persistence>
<hj:default-generated-id name="Hjid">
<orm:generated-value strategy="IDENTITY" />
</hj:default-generated-id>
</hj:persistence>
</jaxb:bindings>