I\'m currently struggling with the right mapping annotations for a scenario using a composite Primary Key Class. First, what I am trying to achieve in words:
I have
I've fixed a similar problem by modifying the mappedBy
attribute of the parent class (using dotted notation)
public class Group{
...
@OneToMany(mappedBy = "fieldAccessRulePK.group")
private Set fieldAccessRules;
...
}
and by keeping the annotations in the PK class:
@Embeddable
public class FieldAccessRulePK implements Serializable{
private String fieldKey;
@ManyToOne
@JoinColumn(name = "group_id")
private Group group;
...
}