Reputation: 862
I need to customize the column names for composite foreign keys in GORM, and I didn't find any document that shows how to do it. I know how to customize PK columns, and how to customize a single-column FK, but not multi-column FK. Is it possible at all?
Thanks.
Upvotes: 11
Views: 2710
Reputation: 24497
A domain class with composite id must implement the Serializable
interface.
class Person implements Serializable {
...
}
Upvotes: 2
Reputation: 2609
You need the "id: composite" construct in your object mapping closure.
I have to leave for work, so here it is in brief:
class Person {
String firstName
String lastName
static mapping = {
id composite:['firstName', 'lastName']
}
}
Grails: Object Relational Mapping
Upvotes: 0