@OneToOne unidirectional and bidirectional

后端 未结 2 1163
礼貌的吻别
礼貌的吻别 2020-12-05 15:53

I have two examples that first is @OneToOne unidirectional mapping and second bidirectional. In unidirectional mapping, the owning-side table must contain a join column that

2条回答
  •  青春惊慌失措
    2020-12-05 16:24

    I just had an experiment on this. If you just do this below, both tables will have foreign keys:

    @OneToOne
    private Address43 address;
    
    @OneToOne
    private Customer44 customer;
    

    Now you don't need to do the join. I am not sure if it is a good practice or not. Just make sure if you don't have CASCADES.

提交回复
热议问题