JPA @OneToMany : foreign key is null

前端 未结 4 614
[愿得一人]
[愿得一人] 2020-12-19 12:39

I need help to define correctly a @OneToMany JPA annotation. Tried different ways but still get error/issues like the foreign key (visitor_revision_id) is null in the visit

4条回答
  •  长情又很酷
    2020-12-19 13:38

    Without a test case showing the failure its difficult to tell.

    Here are some things you can try:

    1. add , nullable = false to the join column annotation on VisitorCharacteristic

    2. set the relationship in both directions Visitor v = new Visitor(); VisitorCharacteristic vc = new VisitorCharacteristic(); v.setVisitorCharacteristicList(Arrays.asList(vc)); vc.setVisitor(v);

提交回复
热议问题