【问题标题】:hyperjaxb3 xsd:string length in JPA entityhyperjaxb3 xsd:JPA 实体中的字符串长度
【发布时间】:2010-09-13 08:27:46
【问题描述】:

我使用 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:simpleContent 上设置 xsd:recriction,即 xsd:xsd:string 的扩展?我是否必须使用我将扩展的 xsd:restriction 定义一个 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 定制全局设置:

感谢您的帮助。

【问题讨论】:

    标签: jpa xsd jaxb hyperjaxb


    【解决方案1】:

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

    Per-type customization for single properties

    【讨论】:

      【解决方案2】:

      第一个问题:这似乎是一个错误/缺失的功能,请提交问题here

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-03-03
        • 2021-05-26
        • 2017-08-19
        • 2012-01-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多