Hi, I am having trouble deleting an entity in a unidirectional manytomany relationship:
@Entity
class Person{
@Id
String id;
}
@Entity
class Group{
@Id
String id;
@ManyToMany
Set<Person> people;
}
I can add people to groups, but when I em.remove() a person, I am getting an error: Caused by: org.apache.derby.iapi.error.StandardException: DELETE on table 'PERSON' caused a violation of foreign key constraint.
I can solve this by explicitly removing the person from the group before calling em.remove(person), but is there a better way to have this done by the persistence manager?
|