We are using Grails with a legacy database and we need to control how ID’s get assigned to domain objects.
We have tried:
id column: "sco_id", generator:'assigned'
but we get the exception:
Batch update returned unexpected row count from update [0]; actual row
count: 0; expected: 1
we have also tried to create a custom ID generator:
public class ScoIdGenerator implements IdentifierGenerator {
public Serializable generate(SessionImplementor session, Object object) {
/*Generate ID here*/
return 8;
}
}
But it seems like the generator is being ignored in this case so we get the error
DEFAULT keyword cannot be used as column has no DEFAULT
I am not sure if these issues are specific to Grails 2.
Any help appreciated?
The issue here was that we were attempting to configure the id with the columns block
Instead we needed to configure the id directly inside the static mapping block