在HIBERNATE中,您可以将多个一对多关系与同一个表ID相关联吗?

时间:2017-05-23 01:39:42

标签: hibernate jpa

所以我试图用Hibernate实现这个: Database Schema

handleError()

这是客户地址实体,而且混淆是确定地址是用于结算还是运送?有没有办法使用isBilling或isShipping?我可以在存储库层执行此操作,在Customer中只有一个(一对多)映射,但如果可能的话,我更愿意使用Hibernate。

@Entity
public class Customer extends AbstractEntity {

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "customer_id")
    private List<CustomerAddress> shippingAddresses;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "customer_id")
    private List<CustomerAddress> billingAddresses;

    // some other stuff that isn't relevant to the problem
}

0 个答案:

没有答案