How do I remove a record from the join table in a many-to-many relationship?
I am using JPA. I have created a many-to-many relationship between users and groups. A MyUser can be in more than one MyGroup and a MyGroup can have more than one MyUser. Pretty straightforward.
Here is some of my code for MyUser:
and for MyGroup:
As you can tell from the code, I have a join table called my_user_group that just has the foreign keys from each table. (You may also notice it is unidirectional. I don't have a need to list the users by group, only the groups by user).
Now to my question--how do I remove a group from a user? I notice that if I remove a group from the List on my object and the perform a merge(), the foreign key records for the removed group are still there.
Any suggestions would be most welcome.