Try something like
static belongsTo = [person:Person]
static mapping = {
person type: Person, {
column name: "fk_first_name"
column name "fk_last_name"
}
}
}
eas wrote:
I have a domain class Person with a composite primary key
I have a one to many relationship between Person and Address.
static hasMany = [address: Address]
static mapping = {
table "Person"
version false
id composite:["firstName", "lastName"]
columns{
...
...
}
}
In the address class, how do I map the composite primary key from Person as a foreign key. In the database, the foreign key columns in the Address table are fk_first_name and fk_last_name.
static belongsTo = [person:Person]
static mapping = {
table "Address"
version false
columns {
person column: ["fk_first_name", "fk_last_name"]
//The mapping above for the person column does not work
}
}
I'm not able to find any documentation regarding this in the grails user guide. I would appreciate any help that you can give me.
Thanks,
eas