2

I'm trying to tell Grails to create columns of a specific length. This works great for strings, however, for columns of NUMBER type, no matter what I try it keeps creating the default NUMBER(10,0) size. I've tried:

static mapping {
  field(precision: 2)
}

I've also tried:

static mapping {
  field(size: 2)
}

Am I missing something? Is this possible?

Harry Muscle
  • 2,247
  • 4
  • 38
  • 62

3 Answers3

0
static mapping = {
  field length: 2
}

You should have tried one last time with length. :-) Refer docs for details.

dmahapatro
  • 49,365
  • 7
  • 88
  • 117
0

Try to use constraints in Grails. Example :

class User {
    static constraints = {
        age min: 18, max: 60
    }
}

Check out the official Grails document about constraints : http://grails.org/doc/latest/guide/single.html#constraints

Phat H. VU
  • 2,350
  • 1
  • 21
  • 30
0
  static mapping = {
       field column: 'field',sqlType: 'NUMBER(14,0)'
     }

Works when dealing with Oracle database.

Though the post is late it might be useful for future reference.

sandeshg
  • 1
  • 3