other register

Thursday, August 06, 2009

Domain Class (Primary Key) Update and Table Generation

If you set dbCreate = "update" in the DataSource.groovy, then every time you change the domain class, the grails will update the table for you. Sometimes if it doesn't (the primary key (strategy) is changed), then drop the table, and restart the grails application. And it will reflect the changes in the domain class.

To use a manually assigned value as a primary key rather than the default auto_increment one, do:

class Person {
String id

static mapping = {
id generator: 'assigned', column: 'id'

No comments: