GORM column names for simple one to many mapping
- by Toby Hobson
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!