Hi, Gentlemen. I need Your help with the following:
I have 2 Entities, say JOB_DESCR and KEYWORD, with many-to-many relationship. We introduced an additional table, JOB_DESCR_JOIN_KEYWORD to handle the relationship. However there's one
tricky peculiarity here: besides the 2 usual columns in the JOB_DESCR_JOIN_KEYWORD table(foreignKeys to JOB_DESCR and KEYWORD) we wanna one more column --> KEYWORD_TYPE (yes, sure it would be logical to have the KEYWORD_TYPE in KEYWORD table, but we already have one, and need one more column like KEYWORD_TYPE in the join column, and this's a client's decision). I use annotations to describe the mapping:
Code:
@Entity
JobDescription {
private List jobKeywordsOfType1;
private List jobKeywordsOfType2;
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "JOB_DESCR_JOIN_KEYWORD",
joinColumns = { @JoinColumn(name = "JOB_DESCR_ID", referencedColumnName = "ID")},
inverseJoinColumns = { @JoinColumn(name = "KEYWORD_ID", referencedColumnName = "ID") })
public getJobKeywordsOfType1() {
return jobKeywordsOfType1;
}
}
So my question is:
is there a way to somehow insert into the JOB_DESCR_JOIN_KEYWORD.KEYWORD_TYPE the value we want to (it'll be different for jobKeywordsOfType1/jobKeywordsOfType2 accordingly) and HOW(which annotation(s) etc) ??? I had to look through a lot of reference documentation and still haven't found a way to accomplish that. Yes, without the additional column with the above configuration preceding the getter ALL works fine. Any help upon the above, gents, would be highly appreciated..