gpt4 book ai didi

java - EclipseLink DDL 生成错误

转载 作者:行者123 更新时间:2023-12-01 14:51:24 25 4
gpt4 key购买 nike

Embeddable 类具有另一个 Entity O/R 映射注释时,我无法使用 EclipseLink 生成 DDL。如何为 O/R 映射生成 DDL?

公司.java

@Entity
public class Company implements Serializable {
.....

@Embedded
private CompanyAddress address;
}

公司地址.java

@Embeddable
public class CompanyAddress implements Serializable {
.....

@Embedded
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "TOWNSHIP_ID", referencedColumnName = "ID")
private Township township;
}

Township.java

@Entity
public class Township implements Serializable {
.....
}

当我生成时,出现以下错误,

Exception [EclipseLink-195] (Eclipse Persistence Services - 2.1.2.v20101206-r8635): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The shared class org.ace.insurance.system.common.company.CompanyAddress must not reference the isolated class org.ace.insurance.system.common.township.Townsh
ip.
Mapping: org.eclipse.persistence.mappings.OneToOneMapping[township]
Descriptor: RelationalDescriptor(org.ace.insurance.system.common.company.CompanyAddress --> [DatabaseTable(COMPANY)])

最佳答案

如果我理解正确的话,您希望 Township 成为一个正常的独立实体。在这种情况下,您应该从 CompanyAddress 的 Township 字段中删除 @Embedded 注释。如果您希望将其嵌入,那么 Township 将需要 @Embeddable 注释而不是 @Entity。

关于java - EclipseLink DDL 生成错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14805646/

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