Search code examples
grailsgrails-orm

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: 'UpdateFileId', 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.


Solution

  • 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