Hi guys,
I need to realize a bidirectional recursive many-to-many association. Here is an excerpt of my model class:
Code:
@Entity
public class Cluster {
@Id
@GeneratedValue
private Long id;
@ManyToMany
private Set<Cluster> consistsOf = new HashSet<Cluster>();
@ManyToMany
private Set<Cluster> partOf = new HashSet<Cluster>();
}
A cluster can consist of many other clusters and can also be contained in an arbitrary number of parent clusters. I learned that I have to use "mappedBy" in a many-to-many relationship to specify the owning side explicitly. I can't really imagine on which side a foreign key might be in this scenario. Can Hibernate/JPA handle this scenario?
Thanks in advance & kind regards
Matt