Access Relationship Table in Grails

Posted by WaZ on Stack Overflow See other posts from Stack Overflow or by WaZ
Published on 2010-03-19T14:10:46Z Indexed on 2010/03/19 14:11 UTC
Read the original article Hit count: 229

Filed under:

Hi, I have the following domains classes:

class Posts{
      String Name
      String Country
      static hasMany = [tags:Tags]

        static constraints = {
        }
    }


class Tags{

    String Name
    static belongsTo = Posts
    static hasMany = [posts:Posts]
    static constraints = {
    }
  String toString()
  {
      "${TypeName}"

  }
}

Grails creates an another table in the database i.e. Posts_Tags.
My requirement is:

E.g. 1 post has 3 tags. So, in the Posts_Tags table there are 3 rows.

How can I access the table Posts_Tags directly in my code so that I can manipulate the data or add some more fields to it.

© Stack Overflow or respective owner

Related posts about grails