[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.rt.eclipselink] Re: ManyToMany: Why is no exception thrown?

JPA does not maintain bi-directional relationships for you. When you remove an object or one side of a relationship you are responsible for maintaining the other side of the relationship.

You do not get the error from one side because it owns the relationship and removes the entries from the join table when being deleted, the other side is read-only so does not, and gets a database constraint error. In both cases your application or model code is responsible for removing all references to the object being deleted.

You could potentially use a preRemove event to traverse your object's relationships and remove its' references. Although if the user is deleting an object that has references you may consider this application logic.

-- James