开发者

MSSQL's varchar(n) equivalent in GORM

I would like to know if it's possible to set the size of VARCHAR column if database is MS SQL 2005. Here's my domain:

class UpdateTable {

    static mapping = {
        table 'UpdateTable'
        id column: 'U开发者_StackOverflow中文版pdateFileId', generator: 'increment'
        version false
        fileName column: 'FileName', size: 50
    }

    String fileName
}

Note that it produces a 'FileName' column with VARCHAR(255). I would like to set it to just VARCHAR(25). Also tried this but it didn't work

static mapping = {
    ..
    fileName column: 'FileName', length: 50
}

Thanks for any leads on this.


ok, i think i found the solution:

static constraints = {
    fileName(maxSize: 25)
}

found this in http://grails.1312388.n4.nabble.com/How-to-map-String-to-something-larger-than-varchar-255-td1326146.html#a1326146


The correct way to do it (or at least as the documentation says) is:

static mapping = {
    fileName sqlType: 'varchar(25)'
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜