A question about JPA Cascade and removing entity

前端 未结 4 730
时光取名叫无心
时光取名叫无心 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 13:02

    That is correct when you have a bi-directional relationship the owner dictates the cascade rules since it is the "owner". The "owned" entity essentially follows orders, it can't give the orders -- so to speak.

提交回复
热议问题