I have a spring 4 app where I\'m trying to delete an instance of an entity from my database. I have the following entity:
@Entity
public class Token impleme
You need to add PreRemove function ,in the class where you have many object as attribute e.g in Education Class which have relation with UserProfile Education.java
private Set userProfiles = new HashSet(0);
@ManyToMany(fetch = FetchType.EAGER, mappedBy = "educations")
public Set getUserProfiles() {
return this.userProfiles;
}
@PreRemove
private void removeEducationFromUsersProfile() {
for (UsersProfile u : usersProfiles) {
u.getEducationses().remove(this);
}
}