A question about JPA Cascade and removing entity

前端 未结 4 726
时光取名叫无心
时光取名叫无心 2021-01-31 12:16

I have two entities called User and UserProfile in my data model. Here is how they are mapped.

Code from User Entity:

@OneToOne(cascade=CascadeType.ALL)
@P         


        
4条回答
  •  清歌不尽
    2021-01-31 12:49

    With JPA 2.x , if you want a cascade remove then use orphanRemoval attribute :

    @OneToMany(orphanRemoval=true)

    check documentation here for more info.

提交回复
热议问题