views:

765

answers:

2

Hi,

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.

+1  A: 

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

Steve Johnson
+1  A: 

A domain class with composite id must implement the Serializable interface.

class Person implements Serializable {
...
}
Sean A.O. Harney

related questions