这是我的EmployeeDetailEntity.java
课程。其中我使用@OnetoOne
注释与名为GenderEntity
的其他实体建立关系。以下是我的EmployeeDetailEntity
@OneToOne
@JoinColumn(name="GenderEntity",referencedColumnName="id")
private GenderEntity gen;
这是我的GenderEntity.java
课程,其中我列出了与EmployeedetailEntity.java
(ReferencedById="id"
)的关系,其中id是主键。
@OneToOne(mappedBy="gen",cascade=CascadeType.ALL)
private EmployeeDetailEntity empdtl;
从实体生成表时我收到错误(生成失败请参阅控制台以获取更多信息),我的控制台如下:
Exception [EclipseLink-93] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The table [GENDERENTITY] is not present in this descriptor.
Descriptor: RelationalDescriptor(entities.PatientTypeEntity --> [DatabaseTable(PATIENTTYPEENTITY)])
Exception [EclipseLink-93] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The table [SHOPPROFILEENTITY] is not present in this descriptor.
Descriptor: RelationalDescriptor(entities.EmployeeDetailEntity --> [DatabaseTable(EMPLOYEEDETAILENTITY)])
Exception [EclipseLink-41] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: A non-read-only mapping must be defined for the sequence number field.
Descriptor: RelationalDescriptor(entities.PatientTypeEntity --> [DatabaseTable(PATIENTTYPEENTITY)])
Exception [EclipseLink-41] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: A non-read-only mapping must be defined for the sequence number field.
Descriptor: RelationalDescriptor(entities.EmployeeDetailEntity --> [DatabaseTable(EMPLOYEEDETAILENTITY)])
描述符例外:
Local Exception Stack:
Exception [EclipseLink-93] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The table [GENDERENTITY] is not present in this descriptor.
Descriptor: RelationalDescriptor(entities.PatientTypeEntity --> [DatabaseTable(PATIENTTYPEENTITY)])
答案 0 :(得分:0)
问题出在下面一行:
@JoinColumn(name="GenderEntity",referencedColumnName="id")
执行以下操作:
有趣的部分是@JoinColumn
注释,它指定作为外键(EMPLOYEE_DETAIL_ID
)的本地列以及它对应的外表的哪一列(EMPLOYEE_ID
)
所以我假设您在GENDER表中有EMPLOYEE_DETAIL_ID
,这是一个重写EMPLOYEE_DETAIL
表主键的外键,而EMPLOYEE_ID
是EMPLOYEE_DETAIL
中的列表。因此,您的最终映射将如下所示:
@JoinColumn(name="EMPLOYEE_DETAIL_ID",referencedColumnName="EMPLOYEE_ID ")
并确保“gen”是EmployeeDetailEntity.java
中的属性,如下所示:
GenderEntity gen;