I have a MySQL table with the ID attribute as autoincremental and I need that, when doing an insert from Grails, the value of the id is auto-completed increasing.
My grails class has the following mapping:
static mapping = {
id column: "id", type: "long", sqlType: "int", generator: 'assigned'
datasource 'dialer'
version false
}
But wanting to make an insert gives me the following error:
Message: ids for this class must be manually assigned before calling save ()
Would they give me a hand? Thank you!
replace generator attributes assigned by
identity
which is for mySQL
static mapping = {
id column: "id", type: "long", sqlType: "int", generator: 'identity'
datasource 'dialer'
version false
}
more infomation about hibernate generator(ctrl + F "IDENTITY")