hyperjaxb3 xsd:JPA 实体中的字符串长度
我使用 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 :maxLength 对 xsd:simpleType 的限制,JPA @Column.length 的值为 maxLength。如何在 xsd:simpleContent(即 xsd:string 的 xsd:extension)上设置 xsd:rescricion?我是否必须使用要扩展的 xsd:restriction 定义复杂类型?如果是的话,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 定制:
<强>
感谢您的帮助。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
第一个问题:这似乎是一个错误/缺失的功能,请在此处提交问题。
First question: it seems to be a bug/missing feature, please file an issue here.
第二个问题:是的,您可以为简单类型配置全局类型映射。
请参阅单个属性的按类型自定义。
Second question: yes, you can configure global type mappings for simple types.
See Per-type customization for single properties.