Maintaining the position of columns in Grails/GORM

Posted by firnnauriel on Stack Overflow See other posts from Stack Overflow or by firnnauriel
Published on 2010-04-06T07:37:25Z Indexed on 2010/04/06 7:43 UTC
Read the original article Hit count: 228

Filed under:
|

Is there a way to fix the position of the columns in a domain? I have this domain:

class SnbrActVector {

    int nid
    String term
    double weight

    static mapping = {
        version false
        id(generator: 'assigned')
    }

    static constraints = {
        nid(blank:false)
        term(blank:false)
        weight(blank:false)
    }
}

This is the schema of the table generated:

CREATE TABLE  `fractor_grailsDEV`.`snbr_act_vector` (
  `id` bigint(20) NOT NULL,
  `weight` double NOT NULL,
  `term` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `nid` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci

It seems that the order of the columns were reversed. Is there a way to make it like this? (order is nid, term, weight)

CREATE TABLE  `fractor_grailsDEV`.`snbr_act_vector` (
  `id` bigint(20) NOT NULL,
  `nid` int(11) NOT NULL,
  `term` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `weight` double NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci

© Stack Overflow or respective owner

Related posts about grails

Related posts about gorm