gpt4 book ai didi

java - 自定义hyperjaxb3生成实体的表名?

转载 作者:行者123 更新时间:2023-12-02 01:09:12 26 4
gpt4 key购买 nike

我有一个 xml 架构,其中有 simpleType(diagnosisCode),如下所示:

<xsd:complexType name="MedicalClaimDetail">
<xsd:element name="diagnosisCode" minOccurs="1" maxOccurs="99">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
<xsd:maxLength value="30"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:complexType>

这生成了一个与子类具有一对多关系的顶级类,如下所示:

具有原始属性和 hyperjaxb 生成类的 transient 属性的父类:

@Entity(name = "MedicalClaimDetail")
@Table(name = "A_ES_MED_CLM_DETAIL")
@Inheritance(strategy = InheritanceType.JOINED)
public class MedicalClaimDetail
implements Serializable, Equals, HashCode
{

private final static long serialVersionUID = 1L;
@XmlElement(required = true)
protected List<String> diagnosisCode;

protected transient List<MedicalClaimDetailDiagnosisCodeItem> diagnosisCodeItems;

@Transient
public List<String> getDiagnosisCode() {
if (diagnosisCode == null) {
diagnosisCode = new ArrayList<String>();
}
return this.diagnosisCode;
}

public void setDiagnosisCode(List<String> diagnosisCode) {
this.diagnosisCode = diagnosisCode;
}

@OneToMany(targetEntity = MedicalClaimDetailDiagnosisCodeItem.class, cascade = {
CascadeType.ALL
})
@JoinColumn(name = "DIAGNOSISCODEITEMS_MEDICALCL_0")
public List<MedicalClaimDetailDiagnosisCodeItem> getDiagnosisCodeItems() {
if (this.diagnosisCodeItems == null) {
this.diagnosisCodeItems = new ArrayList<MedicalClaimDetailDiagnosisCodeItem>();
}
if (ItemUtils.shouldBeWrapped(this.diagnosisCode)) {
this.diagnosisCode = ItemUtils.wrap(this.diagnosisCode, this.diagnosisCodeItems, MedicalClaimDetailDiagnosisCodeItem.class);
}
return this.diagnosisCodeItems;
}

public void setDiagnosisCodeItems(List<MedicalClaimDetailDiagnosisCodeItem> value) {
this.diagnosisCode = null;
this.diagnosisCodeItems = null;
this.diagnosisCodeItems = value;
if (this.diagnosisCodeItems == null) {
this.diagnosisCodeItems = new ArrayList<MedicalClaimDetailDiagnosisCodeItem>();
}
if (ItemUtils.shouldBeWrapped(this.diagnosisCode)) {
this.diagnosisCode = ItemUtils.wrap(this.diagnosisCode, this.diagnosisCodeItems, MedicalClaimDetailDiagnosisCodeItem.class);
}
}

子类为:

@XmlAccessorType(XmlAccessType.FIELD)
@Entity(name = "MedicalClaimDetailDiagnosisCodeItem")
@Table(name = "MEDICALCLAIMDETAILDIAGNOSISC_0")
@Inheritance(strategy = InheritanceType.JOINED)
public class MedicalClaimDetailDiagnosisCodeItem
implements Serializable, Item<String>
{

private final static long serialVersionUID = 1L;
@XmlElement(name = "diagnosisCode", namespace = "http://vo.edge.fm.cms.hhs.gov")
protected String item;
@XmlTransient
protected Long hjid;

@Basic
@Column(name = "ITEM", length = 30)
public String getItem() {
return item;
}

public void setItem(String value) {
this.item = value;
}

@Id
@Column(name = "HJID")
@GeneratedValue(strategy = GenerationType.AUTO)
public Long getHjid() {
return hjid;
}

public void setHjid(Long value) {
this.hjid = value;
}

}

现在的问题:有没有办法自定义自动生成的实体的表名称:MedicalClaimDetailDiagnosisCodeItem,它是 hyperjaxb 生成的表名称 MEDICALCLAIMDETAILDIAGNOSISC_0

我们怎样才能实现这一目标?

最佳答案

我已经解决了这个问题。请参阅下面的代码,使用外部绑定(bind)自定义生成的实体/类的表名称:

    <jaxb:bindings
schemaLocation="xsd/medicalClaim/MedicalClaimDetail.xsd"
node="/xs:schema">

<jaxb:bindings
node="xs:complexType[@name='MedicalClaimDetail']//xs:element[@name='diagnosisCode']">
<hj:generated-class
className="MedicalClaimDetailDiagnosisCodeItem">
<hj:entity>
<orm:table name="A_ES_MED_CLM_DTL_DG_CD_ITM" />
</hj:entity>
</hj:generated-class>
</jaxb:bindings>

</jaxb:bindings>

关于java - 自定义hyperjaxb3生成实体的表名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59608526/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com