O'Reilly logo
  • Ketan Khairnar thinks this is interesting:

Because the StockItem class is the side that persists the relationship, we need to indicate what property on the StockItem class holds the relationship we’re mapping. We do this using the mappedBy attribute on the annotation, as in the following listing.

Listing 7.8. Making the Product–StockItem relationship bidirectional
import javax.persistence.*;

public class Product extends Model {

  public Lon...


Cover of Play for Java


ManyToOne and OneToMany example