GORM column names for simple one to many mapping

Posted by Toby Hobson on Stack Overflow See other posts from Stack Overflow or by Toby Hobson
Published on 2012-08-29T18:43:00Z Indexed on 2012/09/05 21:38 UTC
Read the original article Hit count: 297

Filed under:
|

I have this setup

class User {
  Date lastLogin

  // logins is a history of logins
  static hasMany = [logins : Date]

  def setLastLogin(Date date) {
    if (date) {
      lastLogin = date
      addToLogins(date) 
    }
  }
}

GORM is generating a table MEMBER_LOGINS which currently looks like this:

USER_ID, LOGINS

Instead I would like

USER_ID, DATE

I tried adding a mapping in User

static mapping = {
  logins column: 'date';
}

But that just changed the foreign key so i now have

DATE, LOGINS

How can I change the LOGINS column?

Thanks!

© Stack Overflow or respective owner

Related posts about grails

Related posts about gorm