dev@glassfish.java.net

Delete the ManyToMany relationship...

From: Dyego Souza Dantas Leal <dyego.leal_at_gmail.com>
Date: Mon, 10 Jul 2006 08:54:47 -0300

I'm have this entity mapping:


Class User ( the 'user' table )
Class Group ( the 'group' table )
and the 'user_group' is a joining table with this relationship:


on User class:

@ManyToMany(fetch=FetchType.EAGER,mappedBy = "ugUser")
private java.util.Set <Group> ugGroup = new HashSet<Group>();

on Group class:

@JoinTable(name = "user_group", joinColumns = {_at_JoinColumn(name =
"ug_group", referencedColumnName = "gr_id")}, inverseJoinColumns =
{_at_JoinColumn(name = "ug_user", referencedColumnName = "us_id")})
@ManyToMany(fetch=FetchType.EAGER)
private java.util.Set <User> ugUser = new HashSet<User>();



Ok , at here... nothing new...


One user have MANY GROUPS
One group have Many USERS !!!


OK... but... if the user has 3 groups... what is EJB-QL to delete the
relations for ONE USER ?

ex: User 1 have three groups on relation table (user_group) , what is
EJB-QL to delete groups on user_group ?


Tnks ! this is very important to me...