Do cascades hold only when I specify them on the entity owning the relationship ?
from http://stackoverflow.com/questions/1534599/a-question-on-jpa-cascading
I have two entities called User and UserProfile in my datamodel. 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, corresponding UserProfile entity gets deleted.)
Here is my question:-
- Do cascades hold only when I specify them on the entity owning the relationship ?