I have User class:
class User {
static hasMany = [ project: Project ]
}
and Project:
class Project {
static hasMany = [ users : User ]
static belongsTo = User
}
Anywhere in my code I can do this :
user.project
will return something like :
[project name]
I need a way to delete this relationship for any User. How can I do that? I can find a user project using dynamic finders, criteria query so on, but how do I remove that relationship from a user instance?
Very new to Grails.
Thanks in advance.
Use
removeFrom. Example:In many-to-many relationships, you should manage the associations from the owning side: the one that is the target of the
belongsTo.Note that it would probably be more clear to name the Project association “projects” instead of “project”, since it’s a many-to-many relationship.