June222 / Smart-Factory-Project

0 stars 1 forks source link

OneToMany에서 Many쪽 Table에 insert가 되지 않음. #29

Closed June222 closed 8 months ago

June222 commented 8 months ago

'일' 쪽 Table에는 insert가 잘 되나 '다' 쪽 Table에 인서트가 되지않음.

response는 잘 도착함.

June222 commented 8 months ago

해결

@OneToMany cascade = CascadeType.ALL

@OneToMany Mapping 진행시에 cascade = CascadeType.ALL을 해줘야 삽입이 됨. 해결하는데 도움이 된 링크

@Table
class Steel {
...
    @OneToMany(mappedBy = "steel", orphanRemoval = true, cascade = CascadeType.ALL)
    private List<SteelLabel> labels = new ArrayList<SteelLabel>();
...
}