I have an xsd file which includes an element with an enumeration constraint:
<xs:complexType name="Request">
<xs:sequence>
<xs:element name="CommsAddress" type="xs:string" />
<xs:element name="CommsAddressType">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="EMAIL"/>
<xs:enumeration value="PHONE"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
...
I would like the CommsAddressType
field in the generated Java class to be a generated enum with the values EMAIL
and PHONE
. In turn, I would like Hibernate to automatically generate my database schema with a CommsAddressType
table containing two rows with the values EMAIL
and PHONE
. The Request
table can then simply reference these with a CommsAddressTypeId
column.
Currently, Hyperjaxb3 generates my Request
class with a CommsAddressType
field of type String
:
@XmlElement(name="CommsAddressType")
protected String commsAddressType
and the schema is generated so that the Request
table has a CommsAddressType
column of type VARCHAR
. This will obviously result in a lot of unnecessary duplicated data.
Is there any way of achieving what I described above? Also, as I am exposing the xsd to my customer, I would like to avoid including any jaxb or hyperjaxb tags in the schema if possible.