0
3つのPKカラムを使用して結合全体で@ManyToManyマッピングを使用できますか?3つのIDフィールドを使用してManyToManyを結合/リンクテーブルにマッピングする
私はこれが不可能であると解決策は、私が過去に行ってきた@OneToManyを使用してエンティティを公開することですが、このフィールドは単に私は多分そこに私を保存するためにいくつかの巧妙なマッピングを考えPKであるため、かなり確信していますこの作品。ここに私の '参加' 実体の抜粋ですChssPly
に応じてJamesC
アップデート -
は希望に満ちについて。
@SuppressWarnings("serial")
@Embeddable
public static class Id implements Serializable {
@Column(name = StringPool.Column.APPLICATION_ID)
private Long applicationId;
@Column(name = StringPool.Column.ARTICLECATEGORY_ID)
private Long articleCategoryId;
@Column(name = StringPool.Column.USER_ID)
private Long userId;
public Id() {}
public Id(Long applicationId, Long articleCategoryId, Long userId) {
this.applicationId = applicationId;
this.articleCategoryId = articleCategoryId;
this.userId = userId;
}
public boolean equals(Object o) {
if (o instanceof Id) {
Id that = (Id)o;
return this.applicationId.equals(that.applicationId) &&
this.articleCategoryId.equals(that.articleCategoryId) &&
this.userId.equals(that.userId);
} else {
return false;
}
}
public int hashCode() {
return applicationId.hashCode() + articleCategoryId.hashCode() + userId.hashCode();
}
}
は基本的に同じことを提案しようとしていた –
ありがとうございました。残念ですが、これをOneToManyの設定にリファクタリングしましたが、次回にはわかります。ありがとうございました。 – JamesC