On my current project, I need to deal with a set of XML files containing some financial information and, later on, do some complex queries on that data in order to populate a database schema.
Those XML files are XSD based and I used Hyperjaxb3 maven plugin to generate JPA classes from it and everything seemed to be working fine. Unfortunately, I found and issue that I'm not able to find a solution for even after having spent plenty of hours searching in Hyperjaxb documentation, Google and here.
This is a fragment of an XML file:
<metrics>
<metric name="pi1" type="decimal" periodType="instant" creationDate="">
<label xml:lang="es">Número de personal remunerado</label>
<label xml:lang="en">Number of staff recipient</label>
</metric>
<metric name="md2" type="monetary" periodType="duration" creationDate="">
<label xml:lang="es">Importe devengado en el período actual (flujo)</label>
<label xml:lang="en">Amount awarded in the current period (flow)</label>
</metric>
</metrics>
The issue is related to the label element. Its XSD definition is as follows:
<xs:element name="label">
<xs:complexType mixed="true">
<xs:attribute ref="xml:lang" use="required"/>
</xs:complexType>
</xs:element>
And the generated java class looks like this:
@XmlRootElement(name = "label")
@Entity(name = "Label")
@Table(name = "LABEL")
@Inheritance(strategy = InheritanceType.JOINED)
public class Label implements Serializable, Equals, HashCode {
@XmlValue
protected String content;
...
@Basic
@Column(name = "CONTENT")
public String getContent() {
return content;
}
@Basic
@Column(name = "LANG")
public String getLang() {
return lang;
}
}
My question is, how can I define the length of that "content" column? At the moment, I've been playing around with my bindings file
<jaxb:bindings node="//xs:element[@name='label']">
<hj:basic>
<orm:column length="1024"/>
</hj:basic>
</jaxb:bindings>
but made no difference at all. Oh, by the way, if possible, making changes to the XSD file should be avoided as it is provided by a third party.