現在、プロジェクトに EclipseLink 2.5 を使用していますが、ManyToMany 関係で小さな問題が発生しました。
Identifiable
複合キー (uuid、リビジョン) を定義するマップされたスーパークラスがあります。Entity クラスAppointment
との両方Content
が のサブクラスですIdentifiable
。
Appointment
からへの一方向の ManyToMany リレーションを定義しようとしましたContent
が、EclipseLink が JoinTable を正しく作成していないようです。その中には 2 つの列 (uuid、リビジョン) しかありませんが、4 つあるはずです (関係の両側に 1 つの uuid とリビジョン)。
コードは次のとおりです。
@MappedSuperclass
@IdClass(IdentifiablePK.class)
public abstract class Identifiable implements Serializable {
@Id
@UuidGenerator(name = "uuid")
@GeneratedValue(generator = "uuid")
protected String uuid;
@Id
protected Integer revision;
/* ... */
}
public class Appointment extends Identifiable {
@JoinColumns({
@JoinColumn(columnDefinition = "trainingcontent_uuid", referencedColumnName = "uuid", nullable = false, updatable = false, insertable = false),
@JoinColumn(columnDefinition = "trainingcontent_revision", referencedColumnName = "revision", nullable = false, updatable = false, insertable = false)
})
@ManyToMany(fetch = FetchType.LAZY)
protected List<TrainingContent> trainingContents;
/* ... */
}
public class TrainingContent extends Identifiable {
/* ... */
}
@JoinTable
の代わりに も使用しようとしましたが、EclipseLinkは、複合キーを持つターゲット エンティティに必要な、@JoinColumns
それぞれ不完全なアノテーションが欠落していると不平を言います。@JoinColumns
私は何か間違ったことをしていますか?
こんにちは、チャート