프로파일 테이블은 권한 테이블과 일대일로 많이 연관되어 있습니다. 특권 테이블은 profile_id W privilege_id의 멀티 파트 키를 갖습니다. 프로필 테이블에서 profile_id의 Privilege 테이블에 조인하고 권한 컬렉션을 되찾고 싶습니다. 내 프로필 클래스에서JPA @OneToMany는 다중 부분 키의 일부로 결합합니다.
내가 가진
@OneToMany(fetch = FetchType.LAZY)
@JoinColumn(name = "PROF_ID")
public List<ProfilePrivilegeEO> getProfilePrivileges()
{
return m_profilePrivileges;
}
내 권한 클래스는 내가 정적 위버 말한다 수행 할 때 ProfilePrivilegeId는, 그러나
@Embeddable
public class ProfilePrivilegeId
implements Serializable
{
private Integer m_profileId;
private Integer m_privNumber;
@Column(name = "PROF_ID")
public Integer getProfileId()
{
return m_profileId;
}
@Column(name = "PRIV_NUM")
public Integer getPrivNumber()
{
return m_privNumber;
}
.....
}
입니다
private ProfilePrivilegeId m_profileId;
@EmbeddedId
public ProfilePrivilegeId getProfileId()
{
return m_profileId;
}
있습니다
The @JoinColumns on the annotated element [method getProfilePrivileges] from the entity
class [class com.acme.ProfileEO] is incomplete. When the source entity class uses a
composite primary key, a @JoinColumn must be specified for each join column using the
@JoinColumns. Both the name and the referencedColumnName elements must be specified in
each such @JoinColumn.
그러나 Profile 테이블에는 privilege_ids에 대한 지식이 없습니다 ... JPA가 왜 권한 테이블의 두 키를 지정해야하는지 알지 못합니다. 이유는 jpa가 임의로 결정한 이유입니다. 이걸 작동 시키려면 어떻게해야합니까? (EclipseLInk를 사용하고 있습니다.)
첫 번째 부분은 내가 한 일입니다. 프로파일은 특권에 대한 OneToMany입니다. 다른 방법은 아닙니다. 조인은 profile_id에만 있습니다. – MeBigFatGuy
프로필 개인 정보 취급 방침이란 무엇입니까? @JoinColumns 주석을 넣고 거기에 두 개의 @JoinColumn을 사용하십시오. @OneToMany에서 키는 외부 클래스 인 Privilege (실제로는 실제로 있어야하며 있어야 함)에 있기 때문에 생성 된 스키마에는 부정적으로 영향을 미치지 않습니다. –
ProfilePrivilegeEO는 권한 테이블의 엔티티입니다. 프로필 클래스에서 지정하는 두 개의 @JoinColumn을 가지고 있지는 않습니다. 권한에 대해 알지 못하기 때문입니다. 그게 문제 야. – MeBigFatGuy