Hibernate complains for null @Id in @OneToOne even if it is not null

前端 未结 1 1896
清酒与你
清酒与你 2021-01-22 17:04

I am trying to achieve @OneToOne association, using the same @Id between a Car and a Person. A Person is has an

1条回答
  •  醉话见心
    2021-01-22 17:31

    (Disclaimer: It was not meant to be a Q&A)

    The problem is in @MapsId annotation. Changing it to:

    @MapsId("name") //Here
    @OneToOne
    @JoinColumn(name = "name")
    @OnDelete(action = OnDeleteAction.CASCADE)
    private Person person;
    

    seems to fix the problem.

    0 讨论(0)
提交回复
热议问题