hyperjaxb3 :枚举问题

hyperjaxb3 : Enumeration questions

我正在尝试使用 hyperjaxb3 从三个 .xsd (C14054.xsd, C14054CodeLists.xsd & C14054DataTypes.xsd) available here 和然后整理来自 XML <-> Java <-> Relational.

的数据

hyperjaxb3 在创建关系模式方面已经比我评估过的非常昂贵的商业工具做得更好 - 但我不能完全让它用 Enums 做我想做的事情。

例如在 C14054.xsd 中,'Provider' 元素引用 'RECID'

<xs:element name="Provider">
<xs:complexType>
  <xs:sequence>
    <xs:element ref="RECID" minOccurs="1" maxOccurs="1" />

这又是 'RECIDCodeType'

类型
<xs:element name="RECID" type="RECIDCodeType" />

来自 C14054CodeLists.xsd

<xs:complexType name="RECIDCodeType">
<xs:simpleContent>
  <xs:extension base="RECIDCodeContentType" />
</xs:simpleContent>

它扩展了 RECIDCodeContentType

<xs:simpleType name="RECIDCodeContentType">
<xs:restriction base="xs:string">
  <xs:enumeration value="14054">
    <xs:annotation>
      <xs:documentation>
        <Label>2014/15 AP student record</Label>
      </xs:documentation>
    </xs:annotation>
  </xs:enumeration>
</xs:restriction>

  1. 枚举类型在数据库中创建为 'lookup tables',列 'HJID' 和 'VALUE_'。 table 的主键是否可能是 VALUE_,而不是自动编号 HJID?

即Provider.RECID(我更改了 bindings.xjb 中的列名)的唯一有效条目(在数据库层)可以是“14054”吗?

  1. 是否可以在创建架构时将枚举值持久保存到关系 table 中?

即可以将 14054 作为一行添加到数据库中的 Subpurposecodetype.VALUE_ 列吗?

非常感谢任何人都可以发出的光!

希望这对以后的其他人有所帮助(感谢 lexicore 为我指明了正确的方向!):

内联解决方案:

<xs:simpleType name="RECIDCodeContentType">
<xs:annotation>
    <xs:appinfo>
        <hj:id />
    </xs:appinfo>
</xs:annotation>
<xs:restriction base="xs:string">
  <xs:enumeration value="14054">
    <xs:annotation>
      <xs:documentation>
        <Label>2014/15 AP student record</Label>
      </xs:documentation>
    </xs:annotation>
  </xs:enumeration>
</xs:restriction>

外部绑定文件解决方案:

<jaxb:bindings schemaLocation="C14054CodeLists.xsd" node="/xs:schema">
    <!-- RECIDCodeType : Make VALUE Primary Key -->
    <jaxb:bindings node="xs:simpleType[@name='RECIDCodeContentType']">
        <hj:id />
    </jaxb:bindings>
</jaxb:bindings>

结果:

@Id
@Column(name = "VALUE_")
public String getValue() {
    return value;
}