Foreign key is always null in one to many relation - Spring Boot Data with JPA

后端 未结 3 723
一生所求
一生所求 2021-01-14 07:56

I have two entity classes Country and Language having bi-directional one to many relationship.

Below are the entity classes:



        
3条回答
  •  Happy的楠姐
    2021-01-14 08:53

    Update the setter for languages in Country class to the below :

     public void setLanguages(List languages) {
            this.languages = languages;
            languages.forEach(entity -> entity.setCountry(this));
        }
    

提交回复
热议问题