Entity Relationships
  • One-to-One
One-to-One Example  
  @Entity
  public class Employee {
    ...
    @OneToOne
    public Office getOffice() {
      return office;
    }
    ...
  }

  @Entity
  public class Office {
    ...
    @OneToOne(mappedBy="office") // Employee is the "owner"
    public Employee getEmployee() {
      return office;
    }
    ...
  }
  • One-to-Many
One-to-Many Example  
  • Many-to-Many
Many-to-Many Example