简体   繁体   中英

hyperjaxb3 xsd:string length in JPA entity

I use Hyperjaxb3 to generate JPA entities from XSD schema. I have a xsd:string type that I want to use for description text (text area in the UI):

<xsd:complexType name="Description">
    <xsd:simpleContent>
        <xsd:extension base="**xsd:string**">
            <xsd:attribute name="abc" type="xsd:NCName" use="optional" />
        </xsd:extension>
    </xsd:simpleContent>
</xsd:complexType>

Hyperjaxb3 generates class (entity) Description with attribute value, annotated like this:

@Basic
@Column(name = "VALUE_", **length = 255**)
public String getValue() {
    return value;
}

The questions I have:

I saw that if I put xsd:maxLength restriction on xsd:simpleType, JPA @Column.length has the value of maxLength. How can I set xsd:rescriction on xsd:simpleContent that is xsd:extension of xsd:string? Do I have to define a complexType with xsd:resctriction that I will extend? And if yes, will Hyperjaxb generate @Column.length by my restriction. I tried following:

   <xsd:simpleType name="DescriptionParent">
  <xsd:restriction base="xsd:string">
            <xsd:maxLength value="4096" />
  </xsd:restriction>
    </xsd:simpleType>
    <xsd:complexType name="Description">
        <xsd:simpleContent>
            <xsd:extension base="DescriptionParent">
                <xsd:attribute name="abc" type="xsd:NCName" use="optional" />
            </xsd:extension>
        </xsd:simpleContent>
    </xsd:complexType>

But the JPA column length is still 255.

Is it also possible to set in my JAXB customization (*.xjb file) the lenght of the column for given type (somehow let hyperjaxb know that this is the orm I want to use for my specific type)? Or is it totally out of the way and xsd:maxLength should be used (above) I managed to set it globally for Hyperjaxb customization:

Thanks for your help.

Second question: yes, you can configure global type mappings for simple types.

See Per-type customization for single properties .

第一个问题:这似乎是错误/缺失功能,请在此处提交问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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