JPA
에 eclipselink
을 사용하고 있습니다. 엔티티가 있습니다. 복합 키은 두 개의 필드로 구성됩니다. 다음은 내 Embeddable 기본 키 클래스 필드 (구성원)입니다.Embeddable 클래스 내의 외래 키 매핑
@Embeddable
public class LeavePK {
@ManyToOne(optional = false)
@JoinColumn(name = "staffId", nullable = false)
private Staff staff;
@Temporal(TemporalType.TIMESTAMP)
private Calendar date;
//setters and getters
}
내 엔티티는 직원 관련 데이터를 남겨 개최 할 예정입니다, 그래서 직원 개체를 결합하여 복합 키를 생성하는 일을두고 노력하고 있어요. 내 논리와는 별도로, 임베디드 클래스 내에 외래 키 매핑을 허용하지 않습니다. JPA 도구 -> 엔티티에서 테이블 생성을 사용하려고하면 다음과 같이 오류가 발생하지만 설명하지는 않습니다.
org.eclipse.persistence.exceptions.ValidationException
Exception Description: The mapping [staff] from the embedded ID class [class rs.stapp.entity.LeavePK] is an invalid mapping for this class. An embeddable class that is used with an embedded ID specification (attribute [leavePK] from the source [class rs.stapp.entity.Leave]) can only contain basic mappings. Either remove the non basic mapping or change the embedded ID specification on the source to be embedded.
은 내가 또한 외래 키 (복합 키에서) 키를 가질 수 없습니다, 뜻. 이 ERM을 수행 할 수있는 다른 방법이 있습니까? 도와주세요. 감사합니다