10

I want a many-to-many relationship. Then i have to specify a belongsTo at one side like:

static belongsTo = Answer

But i already have specified a belongsTo as a Map: here the Code

class Answer {

    String text
    static hasMany = [users:User, filters:Filter]
    static belongsTo = [question:Question]
}

class User {
    String name
    static hasMany = [answers:Answer]
    static belongsTo = Answer
}

class Filter {

    String name
    static hasMany = [answers:Answer]
    static belongsTo = [user:User]
    //static belongsTo = Answer

But I can't specify an owner in the Filter because I already have the user owner for the Filter...

How do I do this?

edit: sorry figured out the solution by myself:

class Filter {

    String name
    User user
    static hasMany = [answers:Answer]
    static belongsTo = [User, Answer]
}
user1200271
  • 142
  • 2
  • 8
  • 17
    You should post your solution as an answer and accept it so people can know that this question has been answered. – Jarred Olson Feb 10 '12 at 19:07

1 Answers1

4

Posting the @user1200271 answer, just to remove from the unaswered list.

class Filter {
    String name
    User user
    static hasMany = [answers:Answer]
    static belongsTo = [User, Answer]
}