KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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) @PrimaryKeyJoinColumn public UserProfile getUserProfile(){ return this.userProfile; } public void setUserProfile(UserProfile userProfile){ this.userProfile=userProfile; } Code from UserProfile Entity: @OneToOne(mappedBy="userProfile",cascade=CascadeType.ALL) public User getUser(){ return this.user; } public void setUser(User user){ this.user=user; } As you see, I have a CascadeType.ALL for the user attribute in UserProfile. But when I try deleting the UserProfile entity, the corresponding User entity still stays. (When I try deleting the User entity, the corresponding UserProfile entity gets deleted.) Here is my question:- Do cascades hold only when I specify them on the entity owning the relationship?
Tags (comma-separated)
Save Edits
Cancel