Let´s say that I have entities A, B and C. I would like to create a constraint between this three tables. How can I accomplish that?. I ´ve been looking and what people normally do is create a table with just the id of A and B and then configure on his classes a ManyToMany relationship like this one.
@ManyToMany(cascade = {CascadeType.MERGE})
@JoinTable(name = "A_B",
joinColumns = @JoinColumn(name = "A_id"),
inverseJoinColumns = @JoinColumn(name = "B_id"),
uniqueConstraints = @UniqueConstraint(columnNames = {"A_id", "B_id"}))
But how can I do it for three classes?.
Regards.