JPA not saving foreign key to @OneToMany relation

前端 未结 6 1077
小蘑菇
小蘑菇 2020-12-25 13:50

I\'m using Spring with Hibernate as a JPA provider and are trying to get a @OneToMany (a contact having many phonenumbers) to save the foreign key in the phone numbers table

6条回答
  •  难免孤独
    2020-12-25 14:21

    I don't think the addPhone method is necessary, you only have to set the contact in the phone object:

    phone.setContact(contact);
    

提交回复
热议问题