繁体   English   中英

hyperjaxb3 xsd:JPA实体中的字符串长度

[英]hyperjaxb3 xsd:string length in JPA entity

我使用Hyperjaxb3从XSD架构生成JPA实体。 我有一个xsd:string类型,我想用于描述文本(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生成带有属性值的类(实体)描述,其注释如下:

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

我的问题是:

我看到如果对xsd:simpleType设置xsd:maxLength限制,则JPA @ Column.length的值为maxLength。 如何在xsd:string的xsd:extension的xsd:simpleContent上设置xsd:recriction? 我必须使用xsd:resctriction定义一个complexType,然后将其扩展吗? 如果是的话,Hyperjaxb将根据我的限制生成@ Column.length。 我尝试了以下操作:

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

但是,JPA列长度仍为255。

是否还可以在我的JAXB定制(* .xjb文件)中设置给定类型的列的长度(以某种方式让hyperjaxb知道这是我要用于特定类型的orm)? 还是完全不对,应该使用xsd:maxLength(在上方)我设法为Hyperjaxb定制全局设置了它:

谢谢你的帮助。

第二个问题:是的,您可以为简单类型配置全局类型映射。

请参阅单个属性的按类型自定义

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

暂无
暂无

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

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