Assigning ID for domain objects in Grails via constructor
Update for Grails 2.2+
As of Grails 2.2-RC1 it is possible to simply add a bindable:true
to the constraints
section of the domain class to
allow assignment in the constructor / findOrCreateWhere:
class MyDomain {
static constraints = {
// allow binding of "id" attribute (e.g. in constructor or url parameters)
id bindable: true
}
}