10

I have a domain class having an Integer variable 'code'. my requirement is to make 'code', primary key column for that domain and also auto increment and to remove the default 'id' column from the table created for that doamin.thnks

2 Answers 2

17

use this :

static mapping = {
id name: 'code'
}

more informations here : http://grails.org/doc/2.0.x/ref/Database%20Mapping/id.html

9

Domain classes in Grails by default dictate the way they are mapped to the database using sensible defaults. You can customize these with the ORM Mapping DSL.

Customizes the way the identifier for a domain class is generated with id. See the Grails documentation for id.

static mapping = {
    id column: 'code', type: 'integer'
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.