JPA - @PreRemove method behaviour
问题 I have 2 entities with many-to-many relationship. The Movie Entity is the owner of this relation, so when I want to delete an Actor Entity I use a method annotated @PreRemove to delete any occurrences of Actor ID in Movie cast to avoid "Foreign key violation exception". Movie class @Entity public class Movie extends AbstractBusinessObject{ @ManyToMany private Map<String, Actor> cast; // setters and getters public void removeCastMember(Actor actor){ for (Entry<String, Actor> e : cast.entrySet(