[英]hyperjaxb3 xsd:string length in JPA entity
I use Hyperjaxb3 to generate JPA entities from XSD schema. 我使用Hyperjaxb3从XSD架构生成JPA实体。 I have a xsd:string type that I want to use for description text (text area in the UI): 我有一个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 generates class (entity) Description with attribute value, annotated like this: Hyperjaxb3生成带有属性值的类(实体)描述,其注释如下:
@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. 我看到如果对xsd:simpleType设置xsd:maxLength限制,则JPA @ Column.length的值为maxLength。 How can I set xsd:rescriction on xsd:simpleContent that is xsd:extension of xsd:string? 如何在xsd:string的xsd:extension的xsd:simpleContent上设置xsd:recriction? Do I have to define a complexType with xsd:resctriction that I will extend? 我必须使用xsd:resctriction定义一个complexType,然后将其扩展吗? And if yes, will Hyperjaxb generate @Column.length by my restriction. 如果是的话,Hyperjaxb将根据我的限制生成@ Column.length。 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. 但是,JPA列长度仍为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)? 是否还可以在我的JAXB定制(* .xjb文件)中设置给定类型的列的长度(以某种方式让hyperjaxb知道这是我要用于特定类型的orm)? Or is it totally out of the way and xsd:maxLength should be used (above) I managed to set it globally for Hyperjaxb customization: 还是完全不对,应该使用xsd:maxLength(在上方)我设法为Hyperjaxb定制全局设置了它:
Thanks for your help. 谢谢你的帮助。
Second question: yes, you can configure global type mappings for simple types. 第二个问题:是的,您可以为简单类型配置全局类型映射。
See Per-type customization for single properties . 请参阅单个属性的按类型自定义 。
第一个问题:这似乎是错误/缺失功能,请在此处提交问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.