@Entity
@Table(name="FOO")
public class Foo {
private UUID fooId;
@OneToMany
@JoinTable(name="FOO_BAR",
joinColumns = @JoinColumn(name="fooId"),
inverseJoinColumns = @JoinColumn(name="barId"))
private List<Bar> bars;
}
@Entity
@Table(name="BAR")
public class Bar {
private UUID barId;
@OneToMany
@JoinTable(name="FOO_BAR",
joinColumns = @JoinColumn(name="barId"),
inverseJoinColumns = @JoinColumn(name="fooId"))
private List<Foo> foos;
}
Specifies a relationship between many Foo
objects to many Bar
objects using an intermediate join table that Hibernate manages.
The Foo
objects are stored as rows in a table called FOO
. The Bar
objects are stored as rows in a table called BAR
. The relationships between Foo
and Bar
objects are stored in a table called FOO_BAR
. However this implies that there is no FooBar
object as part of the application.