I'm trying to change the foreign key column name that is used in Visitor
table for User
's id. The column is named now user_id
, I want to change that to who_id
.
Minimal User
Domain Class:
class User {
static hasMany = [
visitor: Visitor
]
String uid
...
}
Minimal Visitor
Domain Class:
class Visitor {
static belongsTo = [user: User]
....
}
I've tried with mappedBy
but with no success, is there another way to use a property from User
as a foreign key in Visitor
?
I think you want to use the mapping static block:
class Visitor {
static belongsTo = [user: User]
static mapping = { user column: 'who_id' }
}