1

I am using grails 2.4 with oracle. Right now if i want to create a row in database table, i simply create a domain object in grails and invoke save() method. I do not currently pass any id into that object though.

new State("MN", "Minnesota").save();

This will create a row and automatically set an id to the id column in the database, because I have specified the id column in domain object's mapper

mapping {
    id column 'state_id'
}

According to the Grails Documentation grails by default uses the native (database inbuilt) id generator.

My question is, if i switch the database to h2 instead of oracle (for a different environment) how would grails manage the id column of the database?

Currently I am getting an error saying "NULL" not allowed in "STATE_ID" (for h2 database) when i create some default data using Bootstrap.groovy. It works fine for oracle.

is there a way to tell grails to use some specific generator only if there is no default one used by database?

Karthik Cherala
  • 312
  • 4
  • 10

0 Answers0