我有一个实体,它对其他实体具有三个外键:
public class MyClass {
// ...
@OneToOne(cascade = CascadeType.ALL, optional = false)
@JoinColumn(name = "customer_id")
public Customer getCustomer() {
return customer;
}
@OneToOne(cascade = CascadeType.ALL, optional = true)
@JoinColumn(name = "creditDossier_id")
public CreditDossier getCreditDossier() {
return creditDossier;
}
@OneToOne(cascade = CascadeType.ALL, optional = true)
@JoinColumn(name = "insuranceDossier_id")
public InsuranceDossier getInsuranceDossier() {
return insuranceDossier;
}
// ...
}
如何添加保证至少有一个 *Dossier 不为空的限制。