- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 hyperjaxb xsd 文件和绑定(bind)配置。如何强制我生成的类实现在另一个 Artifact 中声明的自定义接口(interface)?我知道我可以让他们通过使用扩展另一个类
<xjc:superClass name="com.sample.jpa.entities.BaseEntity"/>
但我还需要它们实现另一个接口(interface)。我怎样才能做到这一点?
最佳答案
免责声明: Hyperjaxb 的作者和 JAXB2-Basics在这里。
您可以使用 Inheritance plugin来自 JAXB2-Basics连同 Hyperjaxb .您既可以扩展一个类,也可以实现一个接口(interface)。该插件还可以处理泛型,因此您甚至可以执行类似 <inheritance:implements>com.acme.foo.MyInterface<com.acme.foo.SomeClass></inheritance:implements>
的操作。 .
简短指南:
通过<arg>-Xinheritance</arg>
启用插件在你的pom.xml
.像这样的东西:
<plugin>
<groupId>org.jvnet.hyperjaxb3</groupId>
<artifactId>maven-hyperjaxb3-plugin</artifactId>
<configuration>
<!--result>mappingFiles</result-->
<roundtripTestClassName>org.jvnet.hyperjaxb3.ejb.tests.cuone.RoundtripTest</roundtripTestClassName>
<args>
<arg>-Xinheritance</arg>
</args>
</configuration>
</plugin>
JAXB2-Basics 是 Hyperjaxb 的依赖项,因此您很可能不需要在此处执行任何其他操作。查看example (对于注释插件,但这并不重要)。
使用 inheritance:extends
自定义您的复杂类型或 inheritance:implements
定制元素。示例:
<jaxb:bindings schemaLocation="schema.xsd" node="/xsd:schema">
<jaxb:bindings node="xsd:complexType[@name='WillBeMadeCloneableType']">
<inheritance:implements>java.lang.Cloneable</inheritance:implements>
</jaxb:bindings>
</jaxb:bindings>
应该是这样吧。
关于java - 设置hyperjaxb映射强制实现外部接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33024067/
如何避免在@Entity注释中声明派生类的完全限定名称?我有以下 xsd: 但它生成以下 java 源代码: @
这是我第一次尝试使用Hyperjaxb3。我有 2 XSD 的片段,如下所示 ContractFullInfo.xsd
我最终成功地摆弄了 HyperJAXB,以便当 XSD 具有复杂类型 A 并且具有复杂类型 B 的 IDREF 时,HyperJAXB 将在两个生成的实体之间生成 @OneToOne JPA 注释。
我读到this link关于 hyperjaxb 中的 fetchtype。从表面上看,似乎只能在xsd文件中添加一个simpleTypefetch-type,然后添加一个为每个complexType
我需要忽略 JPA 注释的 java pojo 中自动生成的 hjid。我可以使用外部绑定(bind)来完成此操作,但是当我尝试使用 JAXB 内联自定义执行相同的操作时,它仍然会创建 hjid。我在
HyperJAXB 为 XSD 1:1 关系生成 @ManyToOne 注释,例如: 或 这不是预期的行为,因为它应该生成 @OneToOne 注释。嗯,自定义指南描述了您可以通过向每个元素定义添
我正在尝试使用 HyperJaxb3 从 xsd 文件生成实体类。它工作正常,但我需要的是在这些类中有 toString() 方法。我得到的只是 hashCode() 和 equals() 方法。我怎
默认配置hyperjaxb正在创建导致 hibernate 的 hibernate 注释产生极其冗长的注释 SQL导致 SQLException 的语句最坏的情况是性能不佳,最好的情况是性能缓慢。具体
我正在使用 this tutorial 设置 hyperjaxb 在 Eclipse 中运行。到目前为止,我已经将其发送到 marshal 和 unmarshal,但它尚未触发 hbm2ddl 在数据
我有一个预定义的 XSD,如下所示: ...
我正在使用 hyperjaxb 从 xsd 文件生成 Java 类。如何配置它来生成 hibernate 注释,并触发 hbm2ddl 创建一个包含生成类表的 MySQL 数据库? 我下载了 hibe
我正在使用 Hyperjaxb 生成 JPA 映射。然后我使用 hibernate3-maven-plugin 生成数据库的 SQL 脚本。我的问题在于我有一个类型,其属性定义如下: sql脚本像这
我是一名优秀的程序员,十分优秀!