Hibernate ManyToOne vs OneToOne

前端 未结 4 2032
长发绾君心
长发绾君心 2020-12-08 00:40

I can\'t see any difference in the schema of a Many-To-One relationship vs a OneToOne relationship:

@Entity
public class Order {

    @ManyToOne
    @JoinCol         


        
4条回答
  •  南方客
    南方客 (楼主)
    2020-12-08 01:05

    There should normally be a unique constraint on the address_id join column in the case of a OneToOne association, to guarantee that only one Order can have a given address.

提交回复
热议问题