a new object was found through a relationship that was not marked cascade PERSIST

后端 未结 4 1198
忘掉有多难
忘掉有多难 2020-12-08 19:35

In trying to get a @OneToMany relationship between Article and HeaderField I probably have the mapping not quite right, resulting in:<

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-08 20:05

    JPA by default provide no cascade feature. So in my case cascade annotation was missing, so I defined it with the @ManyToOne annotation. Please defined cascade type along with @ManyToOne

    Ex:

    @ManyToOne(cascade = CascadeType.PERSIST)
        private Article article = new Article();
    

提交回复
热议问题