I have a Project and ProjectUser entities that relate Many to Many to each other. Problem is when I delete a Project, the ProjectUser related is deleted as well. I would like to avoid this. Is there a way to do that?
Here is the relation in Project
@JoinTable(name = "BUILDER_PROJECT_PROJECT_USER_LINK",
joinColumns = @JoinColumn(name = "PROJECT_ID"),
inverseJoinColumns = @JoinColumn(name = "USER_ID"))
@ManyToMany(cascade = CascadeType.REMOVE)
protected List<ProjectUser> users;
Here is the ProjectUser entity:
@Table(name = "BUILDER_PROJECT_USER")
@Entity(name = "builder$ProjectUser")
public class ProjectUser extends BaseIdentityIdEntity {
@NotNull
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "USER_ID")
protected User user;
public void setUser(User user) {
this.user = user;
}
public User getUser() {
return user;
}
}
Thanks in advance,
James