简体   繁体   English

hyperjaxb3:枚举问题

[英]hyperjaxb3 : Enumeration questions

I am trying to use hyperjaxb3 to create a relational schema from the three .xsd (C14054.xsd, C14054CodeLists.xsd & C14054DataTypes.xsd) available here and then marshal data from XML <-> Java <-> Relational. 我正在尝试使用hyperjaxb3从此处可用的三个.xsd(C14054.xsd,C14054CodeLists.xsd和C14054DataTypes.xsd)创建关系架构,然后从XML <-> Java <-> Relational封送数据。

hyperjaxb3 has already done a better job of creating the relational schema than a very expensive commercial tool I evaluated - but I can't quite get it to do what I want with Enums. 与我评估过的非常昂贵的商业工具相比,hyperjaxb3在创建关系模式方面做得更好,但是我无法完全使用Enums来完成它。

eg in C14054.xsd, the 'Provider' element references 'RECID' 例如在C14054.xsd中,“提供者”元素引用了“ RECID”

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

which in turn is of TYPE 'RECIDCodeType' 依次为“ RECIDCodeType”类型

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

from C14054CodeLists.xsd 来自C14054CodeLists.xsd

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

which extends RECIDCodeContentType 扩展了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. Enumerated types are created in the database as 'lookup tables' with the columns 'HJID' and 'VALUE_'. 枚举类型在数据库中创建为带有“ HJID”和“ VALUE_”列的“查找表”。 Is it possible for the Primary Key of the table to be VALUE_, rather than the autonumber HJID? 该表的主键是否可以是VALUE_,而不是自动编号的HJID?

Ie can the only valid entry (at the database tier) into Provider.RECID (I changed the column name in bindings.xjb) be '14054'? 即,在Provider.RECID(我更改了bindings.xjb中的列名)的唯一有效条目(在数据库层)可以为'14054'吗?

  1. Is it possible for the Enum values to be persisted into the relation tables when the schema is created? 创建架构时,是否有可能将Enum值保留在关系表中?

Ie can 14054 be added as a row to the Subpurposecodetype.VALUE_ column in the database? 即可以将14054作为行添加到数据库的Subpurposecodetype.VALUE_列中?

Many thanks for any light anybody can shed! 非常感谢任何人都能发出的光芒!

Hopefully, this will help some other people in the future (thanks lexicore for pointing me in the right direction!): 希望这会在将来对其他人有所帮助(感谢lexicore为我指出正确的方向!):

Inline solution: 内联解决方案:

<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>

External bindings file solution: 外部绑定文件解决方案:

<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>

Result: 结果:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM