Таблица профиля имеет связь один ко многим с таблицей привилегий. Таблица привилегий имеет составной ключ, profile_id и privilege_id. Я хочу присоединиться из таблицы Profile к таблице Privilege только по profile_id и получить набор привилегий.
В моем классе профиля у меня есть
@OneToMany(fetch = FetchType.LAZY)
@JoinColumn(name = "PROF_ID")
public List<ProfilePrivilegeEO> getProfilePrivileges()
{
return m_profilePrivileges;
}
Мой класс привилегий имеет
private ProfilePrivilegeId m_profileId;
@EmbeddedId
public ProfilePrivilegeId getProfileId()
{
return m_profileId;
}
Где 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;
}
.....
}
Однако, когда я делаю это, статический ткач говорит:
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.)