GORM supports the concept of composite identifiers (identifiers composed from 2 or more properties). It is not an approach we recommend, but is available to you if you need it:
class Person {
String firstName
String lastName static mapping = {
id composite:['firstName', 'lastName']
}
}
The above will create a composite id of the
firstName
and
lastName
properties of the Person class. When you later need to retrieve an instance by id you have to use a prototype of the object itself:
def p = Person.get(new Person(firstName:"Fred", lastName:"Flintstone"))
println p.firstName