I have an example for manytomany relationships take a look and adapt your code to this and I'll think will work.
I have a table ST_Product and St_partner_subsidiary and I have a table ST_Product_subsidiary(which holds one foreign key to st_product and other to st_partner_subsidiary) so I have to map only the tables st_product and st_partner_subsidiary and then I have:
@Entity
@Table(name = "ST_PRODUCT")
public class Product {
// OTHER columns
@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinTable(name = "ST_PRODUCT_SUBSIDIARY", joinColumns = {
@JoinColumn(
name = "PRODUCT_ID",
nullable = false,
updatable = false) },
inverseJoinColumns = { @JoinColumn(name = "PARTNER_SUBSIDIARY_ID",
nullable = false, updatable = false) })
public List<ProductSubsidiary> getProductSubsidiaries() {
return productSubsidiaries;
}
//Other columns
}
You don't map the middle table, you only refer to it in the two Entities in this case you can see ST_PRODUCT_SUBSIDIARY is only refered.
Hope it helps.