Is it possible to use a @ManyToMany mapping across a join using 3 PK columns?
I'm fairly certain this is not possible and the solution is to expose the entity using @OneToMany which I have done in the past, but because this field is simply a PK I thought there maybe some clever mapping to save me this work.
Regards a Hopeful - JamesC
Update in response to ChssPly
Here is a snippet of my 'Join' entity.
@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();
}
}