Creating Class Car Club & Many-To-Many
Adding Create Mappings for Many-To-Many
Adding Delete Mappings for Many-To-Many
Clarification
Many-To-Many deletion
When you try to delete an entity on the non-owning side of a many-to-many relationship that has associations to the other entity you might get a 'violating foreign key constraint' error. What you would have to do then is to manually remove the associations from the non-owning entities' collection. In this case, that would be
// Make sure to have a getter for clubs on Person.java
for (CarClub carClub: person.getClubs()) {
carClub.getMembers().remove(person);
}
Top comments (0)