通过联接表的单向关联
@Entityclass Patient { @oneToMany private Collection<Vehicle> vehicles = new ArrayList<Vehicle>();}@Entityclass Vehicle {}通过联接表的双向关联
@Entityclass Patient { @oneToMany private Collection<Vehicle> vehicles = new ArrayList<Vehicle>();}@Entityclass Vehicle { @ManyToOne(fetch = FetchType.LAZY) private Patient patient;}通过外键进行单向关联
@Entityclass Patient { @oneToMany @JoinColumn private Collection<Vehicle> vehicles = new ArrayList<Vehicle>();}@Entityclass Vehicle {}通过外键进行双向关联
@Entityclass Patient { @oneToMany(mappedBy = "patient") private Collection<Vehicle> vehicles = new ArrayList<Vehicle>();}@Entityclass Vehicle { @ManyToOne(fetch = FetchType.LAZY) private Patient patient;}通过外键与外列名称说明的双向关联
@Entityclass Patient { @oneToMany(mappedBy = "patient") private Collection<Vehicle> vehicles = new ArrayList<Vehicle>();}@Entityclass Vehicle { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name="patient_id") private Patient patient;}这是使用的基本起点@JoinColumn。
要验证的外键(patient_id在Vehicle表)中可以使用患者台真正映射
@JoinColumn(nullable = false)
@Entityclass Vehicle { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name="patient_id", nullable = false) private Patient patient}


