我是hibernate的新手;在我最近的任务中,我被要求创建m_department表并使用具有复合键的现有BSU_EMPLOYEE表(每个部门可以有多个员工)。当我尝试在第三个映射表“m_department_employees”中映射这两个实体时,我收到此错误。有人可以帮我吗?
** org.hibernate.AnnotationException:com.retalix.insync.mdmapi.model.DepartmentEntity.employees引用的com.retalix.insync.mdmapi.model.DepartmentEmployeeEntity未映射到单个属性*的referencedColumnNames(MemberInternalKey,EmployeeInternalKey) *
[department_id] [int] NOT NULL,
[MemberInternalKey] [int] NOT NULL,
[EmployeeInternalKey] [int] NOT NULL
@Entity
@Table(name = "m_department")
public class DepartmentEntity extends BaseEntityDto {
@OneToMany(fetch=FetchType.EAGER)
@JoinTable(name = "m_department_employees",joinColumns = @JoinColumn(name = "department_id"),inverseJoinColumns = {@JoinColumn(name = "MemberInternalKey",referencedColumnName="MemberInternalKey")
,@JoinColumn(name = "EmployeeInternalKey",referencedColumnName = "EmployeeInternalKey") })
private Collection<DepartmentEmployeeEntity> employees = new ArrayList<DepartmentEmployeeEntity>();
@Entity
@Table(name = "BSU_EMPLOYEE")
@AttributeOverrides({
@AttributeOverride(name = "externalID", column =@Column(name="MemberInternalKey",insertable = false,updatable = false)),
@AttributeOverride(name = "internalID", column =@Column(name="EmployeeInternalKey"))})
public class DepartmentEmployeeEntity extends BaseEntityDto {
@EmbeddedId
private DepartmentEmployeeIdClass idClass;
@ManyToOne
private DepartmentEntity departmentEntity;
@Embeddable
public class DepartmentEmployeeIdClass implements Serializable {
@Column(name = "MemberInternalKey" ,unique = false,nullable = false, insertable = true, updatable = true)
private int memberInternalKey;
@Column(name = "EmployeeInternalKey")
private int employeeInternalKey;