@Entity
@Table(name="FOO")
public class Foo {
private UUID fooId;
@OneToMany(mappedBy = "bar")
private List<Bar> bars;
}
@Entity
@Table(name="BAR")
public class Bar {
private UUID barId;
@ManyToOne
@JoinColumn(name = "fooId")
private Foo foo;
}
Specifies a two-way relationship between one Foo
object to many Bar
objects using a foreign key.
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 foreign key is stored on the BAR
table in a column called fooId
.