0

EclipseLink当一个Embeddable类有另一个EntityO/R 映射注释时,我无法使用 生成 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;
}   

乡镇.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)])
4

1 回答 1

1

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

于 2013-02-11T07:03:33.237 回答